Note that there are some explanatory texts on larger screens.

plurals
  1. POForms not updating accordingly
    primarykey
    data
    text
    <p>I am trying to get my form to update specific records withing my db.</p> <p>I have en editing page to edit the record and have now added a upload form for documents for that specific record but when it uploads it only creates a new row with the captured data i.e. the file name and the uploaded file is correctly placed, just not under the relevant record.</p> <p>I got it working!</p> <p>The table where the waning upload form is on:</p> <pre><code> &lt;table cellpadding="5" cellspacing="0"&gt; &lt;form enctype="multipart/form-data" action="includes/add.php?ID=&lt;?php echo "$idnumber" ?&gt;" method="POST"&gt; &lt;input type="hidden" name="idenumber" value="&lt;?php echo $idnumber; ?&gt;"/&gt; &lt;th&gt;Ad Warnings Documents&lt;/th&gt; &lt;tr&gt; &lt;td&gt;Warning File 1&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="warning1" value="&lt;?php echo $warning1;?&gt;" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Warning File 2&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="warning2" value="&lt;?php echo $warning2;?&gt;" &gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Warning File 3&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="warning3" value="&lt;?php echo $warning3;?&gt;"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value="Add"&gt; &lt;/td&gt;&lt;/tr&gt; &lt;/table&gt; </code></pre> <p>The final working upload script</p> <pre><code> &lt;?php include 'core/init.php'; // Connects to your Database include 'includes/overall/header.php'; error_reporting(1); $idnumber = 'idnumber'; $connect_error = 'Sorry, we\'re experiencing connection problems.'; mysql_connect('localhost', '', '') or die($connect_error); mysql_select_db('') or die($connect_error); $query= "SELECT idnumber FROM ref_employees WHERE $idnumber = `idnumber`" or die($connect_error); $idnumber=$_POST['idnumber'] ; //This is the directory where images will be saved $target = "../files/empdocs/"; $target1 = $target . basename( $_FILES['warning1']['name']); $target2 = $target . basename( $_FILES['warning2']['name']); $target3 = $target . basename( $_FILES['warning3']['name']); //This gets all the other information from the form $warning1=($_FILES['warning1']['name']); $warning2=($_FILES['warning2']['name']); $warning3=($_FILES['warning3']['name']); //Writes the information to the database $q = "UPDATE ref_employees SET `warning1` = '$warning1', `warning2` = '$warning2', `warning3` = '$warning3' WHERE $idnumber=`idnumber`"; $res = mysql_query( $q ); if ( ! $res ) { // an error occured } //Writes the file to the server if (move_uploaded_file($_FILES['warning1']['tmp_name'], $target1)) echo "The file ". basename( $_FILES['warning1']['name']). " has been uploaded, and your information has been added to the directory"; if (move_uploaded_file($_FILES['warning2']['tmp_name'], $target2)) echo "The file ". basename( $_FILES['warning2']['name']). " has been uploaded, and your information has been added to the directory"; if (move_uploaded_file($_FILES['warning3']['tmp_name'], $target3)) echo "The file ". basename( $_FILES['warning3']['name']). " has been uploaded, and your information has been added to the directory"; //Tells you if its all ok else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?&gt; &lt;?php include 'includes/overall/footer.php'; ?&gt; </code></pre> <p>Thanks for everyone for your help and guidance.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload