PHP thumnail

Hello, i’ve got a problem with my thumbnail script.
The script works perfectly but my question is how I create a thumbnail


<?php require_once('../Connections/test.php'); ?>
<?php include("../config.inc.php");?>
<?php

// Even de categorie opvragen om door te passen naar de succespagina
    $cat = $_GET['cat'];

// Genereer een unieke naam om straks als bestandsnaam te gebruiken (om overschrijving te voorkomen)
    $uniq = md5(uniqid(""));

//Directory waar de afbeeldingen opgeslagen kunnen worden 
      $dir = "../images/"; 

//Tja, hoe moet ik dit zooitje hieronder nou weer beschrijven... 
    $new_name = $dir.$uniq.".jpg";
    $new_name1 = $uniq.".jpg";

//MIME types die toegestaan zijn om te uploaden
      $types = array("image/gif","image/pjpeg"); 

function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $theValue;

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}

$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
  $editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
  $insertSQL = sprintf("INSERT INTO articles (cat, name, description, price, `date`, picpath) VALUES (%s, %s, %s, %s, %s, '$new_name1')",
                       GetSQLValueString($_POST['cat'], "text"),
                       GetSQLValueString($_POST['name'], "text"),
                       GetSQLValueString($_POST['description'], "text"),
                       GetSQLValueString($_POST['price'], "text"),
                       GetSQLValueString($_POST['date'], "text"));

  mysql_select_db($database_test, $test);
  $Result1 = mysql_query($insertSQL, $test) or die(mysql_error());

  $insertGoTo = "art_insert_success.php";
  if (isset($_SERVER['QUERY_STRING'])) {
    $insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
    $insertGoTo .= $_SERVER['QUERY_STRING'];
  }
  header(sprintf("Location: %s", $insertGoTo));
}

mysql_select_db($database_test, $test);
$query_get_cats = "SELECT * FROM cats ORDER BY name ASC";
$get_cats = mysql_query($query_get_cats, $test) or die(mysql_error());
$row_get_cats = mysql_fetch_assoc($get_cats);
$totalRows_get_cats = mysql_num_rows($get_cats);

//Check to determine if the submit button has been pressed 
    if(isset($_POST['submit'])){ 



//Check MIME Type 
    if (in_array($_FILES['upload']['type'], $types)){ 
      
//Move file from tmp dir to new location 
        move_uploaded_file($_FILES['upload']['tmp_name'], $new_name);
                  
        echo " was uploaded sucessfully!";                  
          
    }else{ 
          
//Print Error Message 
          
    echo "<small>File <strong><em></em></strong> Was Not Uploaded!</small><br />"; 
     
//Debug 
   $name =  $_FILES['upload']['name']; 
   $type =    $_FILES['upload']['type']; 
   $size =    $_FILES['upload']['size']; 
   $tmp =     $_FILES['upload']['name']; 
    
   echo "Name: $name<br/ >Type: $type<br />Size: $size<br />Tmp: $tmp"; 
             
    } 
      
    } 
      
      
else{ 
    echo ''; 
} 
        ?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title><?php echo $appname; ?></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">
<link href="style.css" rel="stylesheet" type="text/css">
</head>

<body>
<br>
<table width="550" height="42" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td height="21" colspan="2"><h3 align="center">Artikel toevoegen </h3></td>
  </tr>
  <tr valign="middle" class="bottomline-solid">
    <td width="275" height="18"><a href="javascript:history.back() "><img src="../assets/back_button.gif" width="52" height="17" border="0"></a></td>
    <td width="275"><div align="right"></div></td>
  </tr>
</table>
<br>
<form action="<?php echo $editFormAction; ?>" method="post" enctype="multipart/form-data" name="form1">
  <table cellpadding="0" cellspacing="0">
    <tr valign="baseline">
      <td width="100" align="right" nowrap>Categorie:</td>
      <td width="15">&nbsp;</td>
      <td width="367"><select name="cat" id="select">
        <?php
do {  
?>
        <option value="<?php echo $row_get_cats['id']?>"<?php if (!(strcmp($row_get_cats['id'], $_GET['cat']))) {echo "SELECTED";} ?>><?php echo $row_get_cats['name']?></option>
        <?php
} while ($row_get_cats = mysql_fetch_assoc($get_cats));
  $rows = mysql_num_rows($get_cats);
  if($rows > 0) {
      mysql_data_seek($get_cats, 0);
      $row_get_cats = mysql_fetch_assoc($get_cats);
  }
?>
      </select></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Datum:</td>
      <td>&nbsp;</td>
      <td><input name="date" type="text" id="date" value="<?php echo date("d-m-Y"); ?>" size="10"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap>Artikelnaam:</td>
      <td>&nbsp;</td>
      <td><input name="name" type="text" id="name" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap>Prijs:</td>
      <td>&nbsp;</td>
      <td><input type="text" name="price" value="" size="32"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">Afbeelding:</td>
      <td>&nbsp;</td>
      <td><input name="upload" type="file" id="upload" size="45"></td>
    </tr>
    <tr valign="baseline">
      <td nowrap align="right">&nbsp;</td>
      <td>&nbsp;</td>
      <td>&nbsp;</td>
    </tr>
    <tr valign="baseline">
      <td align="right" valign="top" nowrap>Omschrijving:</td>
      <td>&nbsp;</td>
      <td><textarea name="description" cols="50" rows="10" id="textarea"></textarea></td>
    </tr>
    <tr valign="baseline">
      <td height="31" align="right" nowrap>&nbsp;</td>
      <td valign="bottom">&nbsp;</td>
      <td valign="bottom"><div align="right">
        <input name="submit" type="submit" value="Toevoegen">
      </div></td>
    </tr>
  </table>
  <input type="hidden" name="MM_insert" value="form1">
</form>
<p>&nbsp;</p>
</body>
</html>
<?php
mysql_free_result($get_cats);
?>


As you can see the scripts generates a unique file ( $uniq = md5(uniqid("")); ) My question is… How do I generate a thumnail of this .jpg file during execution of this script?

Tnx in advance