Secure contact us form with validation
Why Choose This Project?
Almost every website contains a “Contact Us” form, but insecure forms can be exploited by bots, spammers, or attackers for SQL Injection, XSS, or sending fake/malicious data. This project focuses on building a highly secure and validated contact form with client-side + server-side validation, spam protection, and secure data handling.
It’s simple, practical, and an essential project for learning secure web development practices.
What You Get in This Project
-
A responsive contact form with proper input validation.
-
Client-side validation (JavaScript) + Server-side validation (Node.js / Java / PHP).
-
CAPTCHA / reCAPTCHA integration to block spam bots.
-
Secure storage of messages in the database with encryption (optional).
-
Admin dashboard to view messages safely.
Technology Stack
| Layer | Technology |
|---|---|
| Frontend | HTML, CSS, JavaScript, Bootstrap |
| Backend | Node.js (Express) / Java (Spring Boot) / PHP |
| Database | MySQL / PostgreSQL / MongoDB |
| Security | Input Sanitization, Regex Validation, CAPTCHA |
| Auth (Admin) | JWT / Spring Security / PHP Sessions |
Key Features
| Feature | Description |
|---|---|
| Responsive UI | Mobile-friendly form design |
| Input Validation | Name → only alphabets, Email → regex check, Phone → digits only |
| Client-side Validation | Prevents invalid submissions via JS |
| Server-side Validation | Double checks inputs to block bypass attempts |
| CAPTCHA / reCAPTCHA | Stops bots & automated spam |
| Secure Data Handling | Escape special chars → prevent XSS, sanitize SQL queries |
| Message Storage | Save messages to DB securely |
| Email Notification | Admin receives secure email when form is submitted |
| Admin Dashboard | View messages with pagination & search |
| Anti-SPAM Measures | Rate-limiting, IP logging, spam keyword filtering |
How Secure Contact Form Works
1. User Submission
-
User fills in Name, Email, Phone, Message.
-
JS validates inputs before submission.
2. CAPTCHA Verification
-
reCAPTCHA ensures request is from a human, not a bot.
3. Server-side Validation
-
Backend checks for:
-
Email format (regex)
-
Phone → digits only
-
Message length limit
-
No SQL Injection / XSS payloads
-
4. Storage & Notification
-
Valid messages stored in database.
-
Admin receives email notification.
5. Admin Access
-
Admin logs in → views all contact messages securely.
Security Features
-
XSS Protection → Escape HTML in inputs.
-
SQL Injection Prevention → Use prepared statements.
-
Rate Limiting → Limit submissions per IP.
-
CAPTCHA → Block automated bots.
-
Validation Layers → JS + Backend Regex.
-
HTTPS Support → Secure communication.
-
Audit Logs → Track submissions & IP addresses.