PHP Cambiar tamaño de imagen

Tengo un script que carga archivos en el servidor y agrega el nombre de archivo a una base de datos, pero lo que me gustaría hacer es restringir las dimensiones máximas de la imagen antes de cargarla. Por lo tanto, si subo una imagen de 1000 x 500, estará restringida pero conservará sus dimensiones y cambiará a 200 x 100, pero una imagen de 300 x 300 estará restringida a 200 x 200

    <?php 

     //This is the directory where images will be saved 
     $target = "uploads/"; 
     $target = $target . basename( $_FILES['photo']['name']); 

     //This gets all the other information from the form 
     $name=$_POST['name']; 
     $pic=($_FILES['photo']['name']); 

     // Connects to your Database 
     mysql_connect("hostname", "username", "password") or die(mysql_error()) ; 
     mysql_select_db("database") or die(mysql_error()) ; 

     //Writes the information to the database 
     mysql_query("INSERT INTO `table` (name, photo) VALUES ('$name','$pic')") ; 

     //Writes the photo to the server 
     if(move_uploaded_file($_FILES['photo']['tmp_name'], $target)) 
     { 

     //Tells you if its all ok 
     echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; 
     } 
     else { 

     //Gives and error if its not 
     echo "Sorry, there was a problem uploading your file."; 
     } 
     ?> 

Gracias por tu ayud

Respuestas a la pregunta(2)

Su respuesta a la pregunta