0

How can I get the values of a form in a php file while the using the form method post

This works on Sololearn but not on other compilers The HTML <html> <body> <form action="test.php" method="post"> <p>Name: <input type="text" name="name" /> </p> <p>Age: <input type="text" name="age" /></p> <p><input type="submit" name="submit" value="Submit" /></p> </form> </body> </html> The PHP (test.php) <html> <body> Welcome <?php echo $_POST["name"]; ?><br /> Your age: <?php echo $_POST["age"]; ?> </body> </html> Then it shows me this without the form values 👉🏿Welcome Your age👈🏿

2nd May 2020, 8:14 AM
Fred Moses Ali
Fred Moses Ali - avatar
3 Respuestas
+ 3
The code is actually fine enough ! If you install a server (like using xamp) and create two files like below : index.php // your html form test.php // welcome php code Then, after submitting form you'll see the result working as expected.
2nd May 2020, 9:03 AM
Arb Rahim Badsa
Arb Rahim Badsa - avatar
+ 2
You cannot use php here with html better to use AJAX
2nd May 2020, 8:15 AM
Souptik Nath
Souptik Nath - avatar
+ 1
Thanks Rahim
2nd May 2020, 10:15 AM
Fred Moses Ali
Fred Moses Ali - avatar