I want to save the HTML form data to a .txt file on the server. I tried to use HTML+PHP, but nothing happened.
<form action="?survey.php" method="post">
Your E-mail address: <input type="text" id="emails" placeholder="Enter your E-mail address" required email-address><br />
<input type="submit" value="提交">
</form>
<?php
$file_emails = "emails.txt";
$line = 0;
$fp = fopen($file_emails , 'r') or die("open file failure!");
if($fp)
{
while(stream_get_line($fp,8192,"\n"))
{
$line++;
}
fclose($fp);
}
$line++;
$string_emails = "Respondent "+$line+":"+$_POST["emails"]+"\r\n";
file_put_contents($file_emails,$string_emails);
?>