Jump to content

file upload variable name not passing to process.php page


MsKazza

Recommended Posts

Hi all,

 

I have my whole script working only the name of the upload file won't pass to the process.php page.  Any help much appreciated.  Prob just some silly mistake that i made but i can't for the life of me see it.

 

form

 


<form enctype="multipart/form-data" action="process.php" method="POST" name="books" title="Santa_Book">
     <img src="images/book/Enter_your_details.png" width="400" height="60" /><br />
      
  
  
  
  <ul id="inline_list">
<input type="text" name="first_name" id="first_name" value="Text to be displayed here" onfocus="if(this.value==this.defaultValue)this.value='';" onblur="if(this.value=='')this.value=this.defaultValue;"/>


<label for="sur_name" class="inside">Name</label>
		  <input name="sur_name" type="text" id="sur_name" class="inside" />
          
	  <label for="sname">Surname</label>
	  <br />
	  Sex 
          <select name="sex" id="sex">
            <option selected="selected">Please Select....</option>
            <option value="girl">Girl</option>
            <option value="boy">Boy</option>
          </select> 
           <label for="age">Age</label>
          <input type="text" name="age" id="age" />
<br />
          

<label for="house_no">House No.</label>
<input type="text" name="house_no" id="house_no" />         
           <br />
                  			<label for="street">Street Name</label>

<input type="text" name="street" id="street" />
         <br />
                			<label for="town">Town</label>

<input type="text" name="town" id="town" />

        
      <br />
      <br />
       <select name="bscf1" id="bscf1">
         <option selected="selected">Please Select...</option>
         <option value="Brother1">Brother</option>
         <option value="Sister1">Sister</option>
         <option value="Cousin1">Cousin</option>
         <option value="Friend1">Friend</option>
       </select>
                             			<label for="bscf_name1">Friend / Sibling</label>

       <input type="text" name="bscf_name1" id="bscf_name1" />
        
      
     <br />
    <select name="bscf2" id="bscf2">
      <option>Please Select...</option>
         <option value="Brother2">Brother</option>
         <option value="Sister2">Sister</option>
         <option value="Cousin2">Cousin</option>
         <option value="Friend2">Friend</option>
       </select>
       <label for="bscf_name2">Friend / Sibling</label>
       <input type="text" name="bscf_name2" id="bscf_name2" />
        
        
      <br />
                       			<label for="from_name">This book is from...</label>

          <input type="text" name="from_name" id="from_name" />
        
       <br />
          <input name="uploadedfile" type="file" id="uploadedfile" value="Upload Image" />
        
     <br />
   
       



  </ul>


  
<br />
  

<input type="submit" value="Continue" />

</form>
  

 

 

process.php page

 

<?php 
// Database connect
$con = mysql_connect("mysql1.myhost.ie","admin_book","root123");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("book_test", $con);




//Parse Values from Coupon.php Form
$first_name  = mysql_real_escape_string(trim($_POST['first_name']));
$sur_name  = mysql_real_escape_string(trim($_POST['sur_name']));
$sex  = mysql_real_escape_string(trim($_POST['sex']));
$age  = mysql_real_escape_string(trim($_POST['age']));
$house_no = mysql_real_escape_string(trim($_POST['house_no']));
$street = mysql_real_escape_string(trim($_POST['street']));
$town = mysql_real_escape_string(trim($_POST['town']));
$bscf1 = mysql_real_escape_string(trim($_POST['bscf1']));
$bscf_name1 = mysql_real_escape_string(trim($_POST['bscf_name1']));
$bscf2 = mysql_real_escape_string(trim($_POST['bscf2']));
$bscf_name2 = mysql_real_escape_string(trim($_POST['bscf_name2']));
$from_name = mysql_real_escape_string(trim($_POST['from_name']));
$uploadedfile = mysql_real_escape_string(trim($_POST['name']));

if ($sex == 'girl')
{
$his_her = 'her';
} 
else 
{
$his_her = 'his';
}

if ($sex == 'girl')
{
$him_her = 'her';
} 
else 
{
$him_her = 'his';
}


$sql="INSERT INTO details (first_name, sur_name, sex, age, house_no, street, town, bscf1, bscf_name1, andy, bscf2, bscf_name2, his_her, him_her, from_name, uploadedfile)
VALUES
('$first_name','$sur_name','$sex','$age','$house_no','$street','$town','$bscf1','$bscf_name1','and','$bscf2','$bscf_name2','$his_her','$him_her','$from_name','$uploadedfile')";


// Where the file is going to be placed 
$target_path = "uploads/";

/* Add the original filename to our target path.  
Result is "uploads/filename.extension" */
$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

$target_path = "uploads/";

$target_path = $target_path . basename( $_FILES['uploadedfile']['name']); 

if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) {
    echo "The file ".  basename( $_FILES['uploadedfile']['name']). 
    " has been uploaded";
} else{
    echo "There was an error uploading the file, please try again!";
}



echo 'Thank you '. $first_name . ' for entering your details bro.<br />';
echo 'surname is : '. $sur_name . '.<br />';
echo 'sex is :  '. $sex . '.<br />';
echo 'age is: '. $age . ' .<br />';
echo 'bscf friend 1 is :  '. $bscf1 . '.<br />';
echo 'bscf name 1 is :  '. $bscf_name1 . '.<br />';
echo 'bscf friend 2 is :  '. $bscf2 . '.<br />';
echo 'bscf name 2 is :  '. $bscf_name2 . '.<br />';
echo 'his_her is : '. $his_her . ' .<br />';
echo 'him_her is :  '. $him_her . '.<br />';
echo 'From Name is :  '. $from_name . '.<br />';
echo 'Uploaded file is :  '. $uploadedfile . '.<br />';


if (!mysql_query($sql))
  {
  die('Error: ' . mysql_error());
  }

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.