uploading three picures
<p>I've been struggling with this code. I want to upload few pictures at the same time, but it's not getting me anywhere. I want to allow my users to upload three pictures for their ads listing. I appreciate your help.</p>

<pre><code>&lt;?php 
if(isset($_POST['upload']) &amp;&amp; $_FILES['userfile']['size'] &gt; 0 )
$title = clean($_POST['title']);
$description = clean($_POST['description']);
$category = clean($_POST['category']);
$price = clean($_POST['price']);
$name = clean($_POST['name']);
$number = clean($_POST['number']);
$email = clean($_POST['email']);
$subcategory = clean($_POST['subcategory']);
$state = clean($_POST['state']);
$city = clean($_POST['city']);

$imagename = basename($_FILES['userfile']['name']);
// PICTURE UPLOAD SYSTEM
$imagename = basename($_FILES['userfile']['name']);

if(empty($imagename)) {
$error = 1;
echo"&lt;h2 class='error'&gt;Image not found&lt;/h2&gt;".$back; }

if($error != 1 &amp;&amp; $noimg != 1)
{

$filename = stripslashes($_FILES['userfile']['name']);
$extension = substr(strrchr($filename, '.'), 1);
$extension = strtolower($extension);
//if it is not a known extension, we will suppose it is an error and will not       

 // upload the file,  
 //otherwise we will do more tests
}

   if (($extension != "jpg") &amp;&amp; ($extension != "jpeg") &amp;&amp; ($extension != "png") &amp;&amp;   

 ($extension != "gif")) 
    {
    //print error message
        echo "&lt;h2 class='error'&gt; Images Must Be Jpg, Gif, or Png Format!  

 &lt;/h2&gt;".$back.'';
        $errors=1;
    }
    else
    {

$time = time();
$newimage = "photos/" . $time . $imagename;
//echo $newimage;
$result = @move_uploaded_file($_FILES['userfile']['tmp_name'], $newimage);
if(empty($result)) {
$error = 1;
echo "&lt;h2 class='error'&gt;".$lang['MOVING_UPLOAD_FILE']."&lt;/h2&gt;&lt;br/&gt;".$back.""; 
}


$date = date("Y-m-d G:i:s") ; 

$query = "INSERT INTO classifieds (id, title, description, state_id, city_id,  

subcat_id, cat, price, name, number, email, picture, date) VALUES ('', '$title', 

'$description', '$state', '$city', '$subcategory', '$category',  '$price', '$name', 

'$number', '$email', '$newimage', '$date')";

mysql_query($query) or die(mysql_error());
?&gt;
&lt;form action="send.php" method="post" name="form"  enctype="multipart/form-data"&gt;
</code></pre>

<p></p>

<p>
  </p>

<p>Thanks again</p>
