How can i make 2 input boxes for file upload and database insert

Hi i have a script and form where user can upload image and the image name goes into the database and the image to the folder

but now i am i’ve been trying to add another input box on the form to be able to upload 2 files one video and the other an image and send both details to the database but been uncessefull with it i look on the web but i can only see upload to the folder without sending details to datase with more than one file
can someone help i tried set input boxes different names and evrything but only uploads one file and doesnt send the the correct value of the second input box?

here my fom

<form action = 'upload.php' method="POST" enctype="multipart/form-data">
  <input type="text" name="name"  class='text_box' >
<br />
<input type="file" name="image" class='text_box'></td> 
	<br />
       <input type="file" name="video"  class='text_box' >
<br />
<input type="submit" value="Submit" name="Submit" >
  </form> 

this is my upload script

<?php
mysql_connect("localhost", "root", "") or die(mysql_error()) ;
mysql_select_db("upload") or die(mysql_error()) ;

// my file the name of the input area on the form type is the extension of the file
//echo $_FILES["myfile"]["type"];

//myfile is the name of the input area on the form 
$name = $_FILES["image"]["name"]; // name of the file
$type = $_FILES["image"]["type"]; //type of the file
$size = $_FILES["image"]["size"]; //the size of the file
$temp = $_FILES["image"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name
// second file
$name = $_FILES["video"]["name"]; // name of the file
$type = $_FILES["video"]["type"]; //type of the file
$size = $_FILES["video"]["size"]; //the size of the file
$temp = $_FILES["video"]["tmp_name"];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name

$error =array(); // this an empty array where you can then call on all of the error messages
$allowed_exts = array('jpg', 'jpeg', 'png', 'gif','avi'); // array with the following extension name values
$image_type = array('image/jpg', 'image/jpeg', 'image/png', 'image/gif','video/avi'); // array with the following image type values
$location = 'images/'; //location of the file or directory where the file will be stored
$appendic_name = "news".$name;//this append the word [news] before the name so the image would be news[nameofimage].gif

// substr counts the number of carachters and then you the specify how how many you letters you want to cut off from the beginning of the word example drivers.jpg it would cut off dri, and would display vers.jpg
//echo $extension = substr($name, 3);

//using both substr and strpos, strpos it will delete anything before the dot in this case it finds the dot on the $name file deletes and + 1 says read after the last letter you delete because you want to display the letters after the dot. if remove the +1 it will display .gif which what we want is just gif
$extension = strtolower(substr($name, strpos ($name, '.') +1));//strlower turn the extension non capital in case extension is capital example JPG will strtolower will make jpg
// another way of doing is with explode
// $image_ext strtolower(end(explode('.',$name))); will explode from where you want in this case from the dot adn end will display from the end after the explode

$name= $_POST["name"];

     if (isset($image)) // if you choose a file name do the if bellow
       {
       
       // if extension is not equal to any of the variables in the array $allowed_exts error appears
        if(in_array($extension, $allowed_exts) === false )
       {
         $error[] = 'Extension not allowed! gif, jpg, jpeg, png only<br />'; // if no errror read next if line
       }
        // if file type is not equal to any of the variables in array $image_type error appears
        if(in_array($type, $image_type) === false)
       {
          $error[] = 'Type of file not allowed! only images allowed<br />';     
       }
       
           
       // check if  folder exist in the server
        if(!file_exists ($location))
       {
          $error[] = 'No directory ' . $location. ' on the server Please create a folder ' .$location;     
       }
            
     }
     // if no error found do the move upload function
       if (empty($error)){
           if (move_uploaded_file($temp, $location .$appendic_name))
           {
             // insert data into database first are the field name teh values are the variables you want to insert into those fields appendic is the new name of the image
mysql_query("INSERT INTO image (name, image, video)
 VALUES ('$name', '$appendic_name','$video')") ;
 echo $type;
           exit();
           }
         }
       else
          {
        foreach ($error as $error)
           {
               echo $error;
           }
        }
      
     
  
//echo $type;
?>

ok from what i understand (what you are trying to do)
I think you have justed started

$name = $_FILES[“image”][“name”]; // name of the file
$type = $_FILES[“image”][“type”]; //type of the file
$size = $_FILES[“image”][“size”]; //the size of the file
$temp = $_FILES[“image”][“tmp_name”];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name
// second file
$name = $_FILES[“video”][“name”]; // name of the file
$type = $_FILES[“video”][“type”]; //type of the file
$size = $_FILES[“video”][“size”]; //the size of the file
$temp = $_FILES[“video”][“tmp_name”];//temporary file location when click upload it temporary stores on the computer and gives it a temporary name

that means you are always overwriting the things
more over
you are doing things for single upload…
you need to repeat all the process using another variable(at the most basic or you can use loop)

more over
if you do it 2 times make sure you remove exit() from first upload…otherwise the script will exit after first upload
more over
error checking is in wrong place(but this is not cause of your problem)

google multiple file uploading in php …might help

thank you