简体   繁体   中英

How do I access information entered in a form on html on the .php file?

I have tried plenty of methods already including ones on this site. The echo function works for the words on the .php file but it just ignores the form information. Please could someone tell me where I am going wrong. I am using Google Chrome if that matters. This is the .html file.

<!DOCTYPE HTML>
<html> 
<body>

<form action="welcome.php" method="post">
Name: <input type="text" name="name"><br>
E-mail: <input type="text" name="email"><br>
<input type="submit">
</form>

</body>
</html>

and this is the .php file named welcome.php

<html>
<body>

Welcome <?php echo $_POST["name"]; ?><br>
Your email address is: <?php echo $_POST["email"]; ?>

</body>
</html>

and all it displays after entering information and clicking submit, all it displays is:

Welcome 
Your email address is:

I would be very grateful if anyone can help. Thanks in advance.

Say the page name, containing the form, is index.html.

  • Put both the files in your "www/your_project" folder.
  • Type in browser's address bar http://localhost/your_project
  • Provide some input in the form on index.html and hit Submit Query button.
  • You will see your $_POST data on welcome.php

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM