0

The form in my HTML file needs to send data to the PHP file for processing, but every time on the browser page, the code of the PHP file is displayed, and this data is not processed. Like this:
When I put these files on the server for access, they all display:
405 Not Allowednginx/1.21.4

HTML:

<form action="survey.php" method="post">
    Your E-mail address: <input type="text" id="emails" placeholder="Enter your E-mail address"><br />
    <input type="submit" value="提交">
</form>

PHP:

<?php
$file_emails = "emails.txt";
$line = 0;
$fp = fopen($file_emails , 'a+') or die("open file failure!");
if($fp)
{
    while(stream_get_line($fp,8192,"\n"))
    {
        $line++;
    }
    fclose($fp);
}
$fp = fopen($file_emails , 'a+') or die("open file failure!");
$line++;
$string_emails = "Respondent "+$line+":"+$_POST["emails"]+"\r\n";
fwrite($fp,$string_emails);
fclose($fp);
?>  
Kewuaipao
  • 11
  • 1
  • 3
  • This has nothing to do with `javascript` or `html` – Andreas Jul 16 '22 at 17:23
  • Your web server doesn't allow POST requests. – Andreas Jul 16 '22 at 17:24
  • @Andreas But I tried it on my PC, and it showed me the code and did not work. – Kewuaipao Jul 17 '22 at 04:50
  • @Andreas like this:https://i.stack.imgur.com/oJjkG.png – Kewuaipao Jul 17 '22 at 04:55
  • have you configured nginx for serving PHP ? have a look at https://www.theserverside.com/blog/Coffee-Talk-Java-News-Stories-and-Opinions/Nginx-PHP-FPM-config-example – Satya Jul 17 '22 at 06:33
  • @Satya I didn't install nginx by "sudo apt-get install nginx" so the config file a little different from the linked website... But I still made changes to what this site teaches... And nothing happened.. When I click the "Submit" button, the PHP file is automatically downloaded.. – Kewuaipao Jul 17 '22 at 13:33

0 Answers0