A basic PHP contact form example demonstrating how to create an HTML form and handle form submissions securely using PHP.
- Simple contact form with Name and Email fields
- Basic form validation (required fields)
- PHP script to process form data and sanitize inputs to prevent XSS
- Easy to understand and extend for beginners
- A local or remote web server with PHP support (e.g., XAMPP, WAMP, MAMP, or a live server)
- Clone or download this repository.
- Place the files (
form.html
andprocess.php
) in your web server’s root directory or a subfolder. - Open
form.html
in your browser (e.g.,http://localhost/form.html
if running locally). - Fill out the form and submit.
- The form data will be sent to
process.php
and displayed on the page.
form.html
— The HTML contact form for user input.process.php
— PHP script to handle form submission and display sanitized input.
- User inputs are sanitized using
htmlspecialchars()
to prevent Cross-Site Scripting (XSS) attacks.
This project is licensed under the MIT License. See the LICENSE file for details.
Feel free to contribute or suggest improvements!