8000 GitHub - raspgot/Contact-Form-PHP: A modern, lightweight, and secure contact form built with PHP and Bootstrap 5 — powered by AJAX, PHPMailer, and Google reCAPTCHA v3, with zero jQuery dependency
[go: up one dir, main page]

Skip to content

A modern, lightweight, and secure contact form built with PHP and Bootstrap 5 — powered by AJAX, PHPMailer, and Google reCAPTCHA v3, with zero jQuery dependency

Notifications You must be signed in to change notification settings

raspgot/Contact-Form-PHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Contact-Form-PHP

version code size closed issues stars

A modern, lightweight, and secure contact form for any PHP project.
Built with Bootstrap 5, powered by AJAX, PHPMailer, and Google reCAPTCHA v3 — no jQuery, no bloat.
🔐 Designed for performance, accessibility, and clean code.

Demo

🚀 Live Demo

🔗 Try the live demo


✨ Features

  • PHP 8.4+ Ready – Future-proof and modern codebase
  • Responsive Bootstrap 5 UI – Clean, accessible and mobile-friendly
  • AJAX Form Submission – Seamless UX, no page reload
  • Google reCAPTCHA v3 – Invisible and effective spam protection
  • SMTP Email via PHPMailer – Secure, authenticated delivery
  • User-Agent & Honeypot Spam Filtering – No bots allowed
  • Client + Server Validation – Double-layered security
  • Fully Customizable – Easily adapt fields, messages, and style

Want even better spam protection ?

✅ Regex-enhanced bot detection
✅ DNS email domain validation
✅ Honeypot field
✅ reCAPTCHA score filtering


📦 Quick Start

1. Clone the repository

git clone https://github.com/raspgot/Contact-Form-PHP.git

Or download as ZIP.

2. Run it locally

Use a local PHP server like XAMPP, MAMP or PHP's built-in server:

php -S localhost:8000

⚙️ Configuration

1. Set your credentials

Get your reCAPTCHA secret key from Google reCAPTCHA Admin Panel

Edit the following constants in AjaxForm.php:

const SMTP_HOST     = 'your.smtp.com';
const SMTP_USERNAME = 'your@email.com';
const SMTP_PASSWORD = 'yourpassword';
const SECRET_KEY    = 'your_recaptcha_secret_key';

ℹ️ Enable the php_curl extension in your php.ini file:

extension=curl

2. Set your site key in JS

In AjaxForm.js, edit the key:

const RECAPTCHA_SITE_KEY = 'YOUR_RECAPTCHA_SITE_KEY';

And add the reCAPTCHA script at the end of index.html, before </body>:

<script src="https://www.google.com/recaptcha/api.js?render=YOUR_RECAPTCHA_SITE_KEY"></script>

🛠️ Customization

✏️ Change validation messages

Edit them directly in the HTML:

<div class="valid-feedback">Looks good !</div>
<div class="invalid-feedback">Please provide a valid name.</div>

➕ Add new fields

To add fields (e.g. subject or phone):

1. Add the field in index.html:

<input type="text" name="subject" class="form-control" required />

2. Handle it in AjaxForm.php:

$subject = sanitize($_POST['subject']) ?? '';

3. Include it in email_template.php:


🙌 Contributing

Found a bug ? Have a suggestion ? Pull requests and feedback are welcome !


Author

Logo

Developed with ❤️ by Raspgot

If you find this project helpful, don't forget to ⭐ star the repo !


Dependencies

About

A modern, lightweight, and secure contact form built with PHP and Bootstrap 5 — powered by AJAX, PHPMailer, and Google reCAPTCHA v3, with zero jQuery dependency

Topics

Resources

Stars

Watchers

Forks

0