PHP Forms
One of the most important features of PHP. Using forms you can get and recieve information from visitors. You may store that data into a file, place an order, gather user statistics, register the person to your web forum, or maybe subscribe them to your weekly newsletter.
<html>
<body>
<form action="form_submitted.php" method="POST">
Enter your name: <input type="text" name="name">
Enter your email: <input type="text" name="email">
<input type="submit">
</form>
</body>
</html>
<body>
<form action="form_submitted.php" method="POST">
Enter your name: <input type="text" name="name">
Enter your email: <input type="text" name="email">
<input type="submit">
</form>
</body>
</html>
The
above example HTML page contains two input fields and a submit button. When
the user fills the form and clicks submit button, then "form_submitted.php"
file is called.
The "form_submitted.php" file looks like this:
<html>
<body>
Hello <?=$name?>!<br>
Your email address is:<?=$email?>
</body>
</html>
<body>
Hello <?=$name?>!<br>
Your email address is:<?=$email?>
</body>
</html>
Output
Hello
Smith
Your email Address is: marksmith@hotmail.com
Your email Address is: marksmith@hotmail.com
In this example, two variables are used $name and $email. actually $name and $email are name of textfields.