Unable to find a way to resize an image using PHP


I want to resize any image uploaded to 200*200 pixels.I have been looking over scripts all over the net,have found many but unable to use any.I don't want any other controls just resizing it to specific size.

<!-<?php session_start();?>
<?php session_start();?>
<?php $u_name=birju;?>
<?php require_once("mydb.php");?>

         define ("MAX_SIZE","100"); 

         function getExtension($str) {
                 $i = strrpos($str,".");
                 if (!$i) { return ""; }
                 $l = strlen($str) - $i;
                 $ext = substr($str,$i+1,$l);
                 return $ext;


            if ($image)
                $filename = stripslashes($_FILES['image']['name']);
                $extension = getExtension($filename);
                $extension = strtolower($extension);
         if (($extension != "jpg") && ($extension != "jpeg") && ($extension != "png") && ($extension != "gif"))
                    echo '<h1>Unknown extension!</h1>';

        if ($size > MAX_SIZE*1024)
            echo '<h1>You have exceeded the size limit!</h1>';

        $image_name = $u_name.'.'.$extension;
        $copied = copy($_FILES['image']['tmp_name'], $newname);
        if (!$copied)
            echo '<h1>Copy unsuccessfull!</h1>';

         $me=mysql_query("insert into img_upload values(\"\",\"$u_name\",\"$newname\")");
             die("database query failed".mysql_error());


         <!--next comes the form, you must set the enctype to "multipart/frm-data" and use an input type "file" -->
         <form name="newad" method="post" enctype="multipart/form-data"  action="">
            <tr><td><input type="file" name="image"></td></tr>
            <tr><td><input name="Submit" type="submit" value="Upload image"></td></tr>

Using PHP GD, instead of your code about copying the image from tmp_name to new_name use:

$image = file_get_contents($_FILES['image']['tmp_name']);
$new_image = imagecreatetruecolor(200, 200);
imagecopyresampled($new_image, $image, 0, 0, 0, 0, 200, 200, imagesx($image), imagesy($image));
file_put_contents($newname, $new_image);