Below is an example of a simple HTML form featuring two input fields and a submit button:
<html> |
When the user fills out the form above and clicks the submit button, the form data is sent for processing to a PHP file named “welcome.php” using the HTTP POST method.
To display the submitted data, you can use PHP to echo all the variables.
The content of “welcome.php” is as follows:
<html>
</body> |
Here’s an example of what the output could look like:
|
The same result could also be achieved using the HTTP GET method:
Here’s the same example, but with the method set to GET instead of POST:
<html> <form action="welcome_get.php" method="GET"> </body> |
and the “welcome_get.php” file looks like this:
<html>
</body> |
The code above is quite simple and does not include any validation.
It is essential to validate form data to protect your script from malicious code.
Think SECURITY when processing PHP forms! This page does not include any form validation; it only demonstrates how to send and retrieve form data. However, the following pages will show how to process PHP forms with security in mind. Proper validation of form data is crucial to protect your forms from hackers and spammers! |