I am trying to create a HTML form in which users can fill in their information and submit it. The information should then be printed to a text file (or email). The script works, however, after a successful submission, it will send from 2-6 additional blank forms to the text file or email. I don't believe it's a problem with my code, but here it is: The HTML form:
<HTML>
<HEAD>
<u><b>Physician Information</b></u>
</HEAD>
<BODY>
<form action="Success.php" method="POST">
<p> Name: <input type="text" name="name" size="30"/></p>
<p> Email: <input type="text" name="email" size="30"/></p>
<p> Gender: <input type="radio" name="gender" value="Male"/>Male <input type="radio" name="gender" value="Female"/>Female</p>
<p> Job: <input type="radio" name="job" value="Physician"/>Physician <input type="radio" name="job" value="Nurse"/>Nurse</p>
<p>State: <select name="state">
<option value="New York">New York</option>
<option value="California">California</option>
<option value="Washington">Washington</option>
<option value="Illinois">Illinois</option>
</select></p>
<p>Language: <select name="language">
<option value="Chinese">Chinese</option>
<option value="Korean">Korean</option>
<option value="Vietnamese">Vietnamese</option>
</select></p>
</br>
<input type="submit" name="submit" value="Submit"/>
</BODY>
</HTML>
And the PHP script:
<?PHP
$Name=$_POST['name'];
$Email=$_POST['email'];
$Gender=$_POST['gender'];
$Job=$_POST['job'];
$State=$_POST['state'];
$Language=$_POST['language'];
$File="Database.html";
$Data= "$Name, $Email, $Gender, $Job, $State, $Language";
file_put_contents($File, $Data . PHP_EOL, FILE_APPEND);
echo "Submission successful. Thank you!";
?>
The output should look something like this:
Name1, Email@email.com, Male, Physician, California, Korean
Name2, Email@email.com, Male, Physician, New York, Chinese
Name3,Email@email.com, Male, Physician, New York, Vietnamese
Instead it looks like this:
Name1, Email@email.com, Male, Physician, California, Korean,,,,,,,,,,,Name2, Email@email.com, Male, Physician, New York, Chinese,,,,,,,,,,Name3,Email@email.com, Male, Physician, New York, Vietnamese,,,,,,,,,,
If I send it via email using the mail() function, it will do the same thing, except it will send one email with the information filled in, followed by two to six blank emails with no information.
Is this a problem with the code or could it be caused by some other source?