Forms are an essential way to collect data from users. HTML forms use GET or POST methods to submit data to PHP scripts for processing.
Simple Form Example
Here’s a basic form where the user submits their name and email.
<!DOCTYPE html>
<html>
<body>
<h2>User Information Form</h2>
<form action="process_form.php" method="POST">
Name: <input type="text" name="name"><br><br>
Email: <input type="email" name="email"><br><br>
<input type="submit" value="Submit">
</form>
</body>
</html>
In this example:
- action specifies the PHP file to handle the form data.
- method=”POST” sends data securely without displaying it in the URL.