Note that there are some explanatory texts on larger screens.

plurals
  1. POUploading of files and saving
    text
    copied!<p>back again</p> <p>So I have moved the code around a bit and now only get the unsuccessfull message. Please tell me where and what I am doing wrong.</p> <p>My form on the editemployee.php page</p> <pre><code>&lt;h1&gt;Warnings&lt;/h1&gt; &lt;div class="article" style="width:535px"&gt; &lt;form enctype="multipart/form-data" action="includes/add.php" method="POST"&gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;Warning letter:&lt;/td&gt; &lt;td&gt; &lt;input type="file" name="warning1"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Warning letter:&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="warning2"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Warning letter Final:&lt;/td&gt; &lt;td&gt;&lt;input type="file" name="warning3"&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;/td&gt; &lt;td&gt;&lt;input type="submit" value="Add"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form&gt; &lt;/div&gt; </code></pre> <p>An now I have move the processing code as suggested to its own file called add.php</p> <pre><code>&lt;?php //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']); // Connects to your Database mysql_connect("localhost", "username", "password") or die(mysql_error()) ; mysql_select_db("database") or die(mysql_error()) ; //Writes the information to the database mysql_query("INSERT INTO ref_employees VALUES ('$warning1', '$warning2', '$warning3')") ; //Writes the file to the server if (move_uploaded_file($_FILES['warning1']['tmp_name'], $target1) &amp;&amp; move_uploaded_file($_FILES['warning2']['tmp_name'], $target2) &amp;&amp; move_uploaded_file($_FILES['warning3']['tmp_name'], $target3)) { //Tells you if its all ok echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded, and your information has been added to the directory"; } else { //Gives and error if its not echo "Sorry, there was a problem uploading your file."; } ?&gt; </code></pre>
 

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