Skip to content

A secure, modern PHP contact form solution using AJAX, Google reCAPTCHA v3, Bootstrap 5, and PHPMailer. Includes spam protection with honeypot, validation, and SMTP support

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, secure, and customizable 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


✨ Features

  • PHP 8+ Ready – Strictly typed and future-proof
  • Bootstrap 5 UI – Responsive and accessible
  • AJAX Submission – No page reloads
  • Google reCAPTCHA v3 – Invisible spam protection
  • SMTP Delivery with PHPMailer – Secure emails
  • Auto-reply to users – Confirm receipt
  • Disposable email detection – Block throwaway addresses
  • Honeypot spam traps – Catch bots
  • Session-based rate limiting – Prevent abuse
  • Easy customization – Tailor fields and styles

🚀 Live Demo

🔗 View the demo


📦 Quick Start

  1. Clone the repository :
git clone https://github.com/raspgot/Contact-Form-PHP.git

Or download as ZIP.

  1. Run it locally :

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

php -S localhost:8000

⚙️ Configuration

1. Set credentials

Get your reCAPTCHA secret key at Google reCAPTCHA.

In AjaxForm.php, edit:

const SECRET_KEY    = 'your_recaptcha_secret_key';
const SMTP_HOST     = 'smtp.yourprovider.com';
const SMTP_USERNAME = 'you@example.com';
const SMTP_PASSWORD = 'yourpassword';
const SMTP_SECURE   = 'tls'; // 'tls' (recommended) or 'ssl'
const SMTP_PORT     = 587;

Note: Enable php_curl in php.ini:

extension=curl

2. Set reCAPTCHA site key in JS

In AjaxForm.js:

const RECAPTCHA_SITE_KEY = 'YOUR_RECAPTCHA_SITE_KEY';

And in index.html:

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

🛠️ Customization

✏️ Change validation messages

Edit the messages in index.html:

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

✨ Advanced Features

  • Regex-based User-Agent detection (blocks common bots)
  • DNS and disposable email validation (rejects throwaway emails)
  • reCAPTCHA score filtering (requires min. score 0.5)
  • Honeypot hidden field (traps bots)
  • Session rate limiting (max 3 submissions per hour)
  • Input sanitization to prevent header injection and XSS
  • Automatic user acknowledgment email
  • Customizable email template with dynamic data

🙌 Contributing

Feel free to open issues or submit pull requests :)


🧑‍💻 Author

Logo
Developed by Raspgotcontact@raspgot.fr

If you find this project useful, please ⭐ star the repository !


📚 Dependencies