A simple contact form that sends an email to the site owner using PHP, jQuery, AJAX, Bootstrap, CSS, and MySQL.
Topics: PHP, Contact Form, Email, AJAX, jQuery, Bootstrap, CSS, MySQL PDO, Web Development
- Simple contact form
- Email notification to site owner
- Stores messages in the database
-
Clone the Repository:
git clone https://github.com/yourusername/simple-contact-form.git cd simple-contact-form
-
Database Setup:
- Create a new MySQL database.
- Import the provided
database.sql
file to set up the necessary table. - Update the database configuration in
config.php
. - Import the provided SQL file to set up the necessary tables.
mysql -u yourusername -p contact_form_db < database.sql
-
Configure the Database Connection:
- Open the
config.php
file and update the database credentials.<?php define('DB_HOST', 'localhost'); define('DB_NAME', 'contact_form_db'); define('DB_USER', 'root'); define('DB_PASS', 'password'); ?>
- Open the
-
Set Up Email Services:
- Update the
send_email.php
file with your email configuration.
- Update the
-
Start a Local PHP Server:
- Start the PHP built-in server.
php -S localhost:8000
- Start the PHP built-in server.
-
Access the Application:
- Open your web browser and navigate to
https://localhost:8000
.
- Open your web browser and navigate to
- Open the application in your web browser.
- Fill out the contact form and submit.
- The message will be sent to the site owner's email and stored in the database.
Here’s a basic file structure for your simple-contact-form application:
simple-contact-form/
├── css/
│ └── styles.css
├── js/
│ └── script.js
├── config.php
├── index.php
├── process_form.php
├── send_email.php
└── README.md