PHP Form, Form Processing


PHP Form, Form Processing


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". The form data is sent with the HTTP
POST method. To display the submitted data you could simply echo all the variables.

PHP Form Handling The most important thing to notice when dealing with HTML forms and
PHP is that any form element in an HTML page will automatically be available to your PHP
scripts. Example The example below contains an HTML form with two input fields and a
submit button:
PHP Form

When a user fills out the form above and click on the submit button, the form data is sent to
a PHP file, called "welcome.php": "welcome.php" looks like this:

Welcome ! Manas –Class Rep
You are 19 years old.

Program:

<html>
<body>
<form action="welcome.php" method="post">
Name: <input type="text" name="fname" />
Age: <input type="text" name="age" />
<input type="submit" />
</form></body></html>

When a user fills out the form above and click on the submit button, the form data is sent to
a PHP file, called "welcome.php": "welcome.php" looks like this:

<html>
<body>
Welcome <?php echo $_POST["fname"]; ?>!<br />
You are <?php echo $_POST["age"]; ?> years old.
</body>
</html>

Output:
Welcome Manas! You are 19 years old.

Custom Search

%d bloggers like this: