Note that there are some explanatory texts on larger screens.

plurals
  1. POIssues writing HTML form fields to text file
    primarykey
    data
    text
    <p>I'm trying to write the contents of a HTML form field to a text file on my web server.</p> <p>I was able to get code I found on an example to work in a plain PHP file, but not in my desired file. </p> <p>Whenever I submit the form, PHP throws an error. <code>PHP Notice: Undefined index: person in &lt;snip&gt;/upload.php on line 26, referer: &lt;snip&gt;/upload</code> </p> <p>Here's the code of the file I want to log:</p> <pre><code>&lt;?php //Delete Current Files $dirfiles = glob('&lt;snip&gt;/uploads/*'); // get all file names foreach($dirfiles as $dirfile){ // iterate files if(is_file($dirfile)) unlink($dirfile); // delete file } //Upload New Files foreach ($_FILES["images"]["error"] as $key =&gt; $error) { if ($error == UPLOAD_ERR_OK) { $name = $_FILES["images"]["name"][$key]; move_uploaded_file( $_FILES["images"]["tmp_name"][$key], "uploads/" . $_FILES['images']['name'][$key]); } } echo "&lt;h2&gt;Successfully Uploaded Images&lt;/h2&gt;"; //Log $when = date("F j, Y, g:i a"); $who = $_POST["person"]; $out = fopen("output.txt", "a"); if (!$out) { print("Could not append to file"); exit; } fputs($out,"$who\t"); fputs($out,"$when\t"); fputs($out,"$_SERVER[REMOTE_ADDR]\n"); print("Name, Time, Date, and IP Address have been recorded."); ?&gt; </code></pre> <p>In the log file, date and IP address are logged fine, but not the name. (Like This)</p> <p><code>February 11, 2013, 3:26 am IPADDR</code></p> <p>where the name should be at the beginning like</p> <p><code>JohnDoe February 11, 2013, 3:26 am IPADDR</code></p> <p>In the original form file, it's just a typical form:</p> <pre><code>&lt;form method="post" action="upload.php"&gt; &lt;input type="text" name="person" /&gt; Your Name&lt;br /&gt; snip... &lt;/form&gt; </code></pre> <p>The only difference between the form where the logging worked and where it didn't was that this one also allows for image uploading via <code>&lt;input type="file" name="images" id="images" multiple /&gt;</code></p> <p>What on earth would be causing the name not to be logged?</p> <p>Edit: Update - It turns out thus bug is not present in Internet Explorer, but still is present in Chrome and Firefox. That's really strange.</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.
    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