Back in the autumn of 2008, I have written a tutorial about how you can create a basic AJAX Contact Form that works with PHP Back-end. The post is one of the most popular here on BitRepository having over 8,000 monthly page views and over 440 comments so far.
Since many people asked me how they can do this and even hired me to offer them assistance with this application, I have decided to write a more advanced script with many features including CAPTCHA and Real-time Validation.
The script can be practically used to create any type of AJAXified, yet secure form that collects data and sends it to your email inbox including but not limited to:
Contact/Feedback Form
Support Form
Customer Survey Form
Online Product Order Form
Event Registration Form
Employment Form
Make a Room Reservation Online Form
Send Testimonial Form
Subscribe to Newsletter Form
Gift Order Form
See some samples of these generated forms
[nggallery id=1]
Some of the features you get with AJAX Form Pro
RealTime Validator
This makes the form completion process interactive. The errors show/hide as the user fills the form. If this feature is disabled, then all the errors will show above the form after the user clicks the submit button.
CAPTCHA: Anti-Spam Verification Image
You may use letters, numbers or both (could be} enabled/disabled). The verification image can be refreshed if the user has trouble discerning the characters. As the user types the security code the script verifies it in the background. If the user types the correct code, it automatically shows (in real-time) a successful message. As opposed to many AJAX CAPTCHAs out there that rely on JavaScript as an Anti-spam measure and have a medium security level, the one I have chosen to implement uses PHP to securely generate and register the required code in the background. The comparison is a case-insensitive one in order to make the completing process simpler without irritating the one who fills thee security code.
Fully (CSS & HTML) Customizable: Supports any form element
Easily add/remove fields, change notifications, customize the mail settings. The following fields are supported: input text boxes, textareas, single/multiple selects, checkboxes, radios. This way, you can create more complex web forms and surveys without editing any HTML code.
Auto Responder
Useful to notify your visitors that their message was successfully sent (e.g. “Your message has been successfully sent. We will reply to your inquiry within 48 hours.”). For example, you can use it while you are in holiday and notify the visitors that you will reply to them at the earliest opportunity.
Becomes a simple PHP Contact Form if JavaScript is disabled
Is the visitor in that 3% of people which have JavaScript disabled? Don’t worry about it! The form automatically turns into a simple non-AJAX PHP Contact Form.
Tableless
Redirect to Thank You page after Successful Submission
If you do not want to show the basic successful confirmation message, you can redirect the user to a customized thank you page.
Send mails using either mail() function or through SMTP
Besides the basic mail() function, you can use the SMTP method to send the mail. This way, chances are higher the message won’t end in the JUNK/SPAM folder, especially if lot of mails are sent 😉
100% Source Code Available
You have the possibility to customize the script as you wish. NO encrypted or obfuscated code!
Documentation
A help page that guides you through the setup process (1. Basic Settings, 2. HTML Structure, 3. CSS Files and Structure, 4. JavaScript, 5. Sources and Credits)
Additional features include:
The e-mail templates (message, subject) are customizable
The errors and the notifications can be easily changed
The script works in conjunction with other libraries beside jQuery such as MooTools or Prototype
Set a custom subject for the mail that you receive if the subject field is removed
Server Requirements
PHP5+
GD Library Enabled (only if you want to use the Anti-Spam Image)
Browser Compatibility
This script is compatible with all major browsers.
It was tested in FireFox 3.5, IE 6, IE 7 & IE 8, Google Chrome 3.0, Opera 10, Safari 4.0, SeaMonkey 2.0, Flock 2.5.6
View Demo Buy Now (from $19)or Get AJAX Form Pro Lite
Licenses are lifetime
Customer Support is offered within 24 hours
Payments are processed through PayPal or 2Checkout
Customer Testimonials
“Very nice! We went through 8 different scripts, only to be frustrated with broken code, links, and tutorials, to finally find one so simple, beautiful and it works! We are avid PHP programmers, but are not yet too versed with AJAX, so this solution was perfect! Thanks” –
“I had a real need for a clean and stylish contact form. I tried some 11 forms before I decided on one. I have to say your form was the winning choice hands down.” –
“It works very good and it solved the problem of needing a form validation as well a as a success message in the same page.” –
“I am working a project for patisserie web site in Turkey and i used your form form this web site contact page. Belong to me, your form is very useful and successful, thanks a lot.” –
Get a Free Lite Version of this AJAX Form
If you’re not sure this is the right product for you, I suggest you get a LITE version of this script that has some similar features. Although it will show you just a fraction of what AJAX Form Pro v2 can do, you can decide later if the purchasing the premium version is worthy or not. Note that you must feel comfortable uploading files through FTP and doing basic updates on the configuration file such as adding your e-mail address.
This version is available for BitRepository.com subscribers. Type your details below, confirm your email and you will receive the download link in your inbox.
I am new to jquery php.please help me on this issue to resolve.
I have html contactus form with captcha.My requirement is .I have to validate the captcha before the form is being submitted . because the control values will be disappear .so that user has to reenter it with captcha.
I used to send a ajax request to check the captcha ,its working . but the form also being submitted .form field values disappear. here the code please correct me where I am wrong
Got a question that you can’t ask on public Stack Overflow? Learn more about sharing private information with Stack Overflow for Teams.
Not the answer you're looking for? Browse other questions tagged jqueryajaxcaptcha or ask your own question.
Follow our PHP contact form script tutorial below or sign up for 123FormBuilder to build your own PHP contact form without coding. Get started for free!
Create a form
Process simple PHP contact form data without disruption
Elvis presley discografia download. Contact forms are the easiest way to let your visitors get in touch with you. They also let you avoid revealing your email address on the web, which can attract spam.
You can build contact forms using various scripting languages, but PHP is one of the most popular. It's very flexible and simplifies connecting to databases, but it isn't always easy to learn, especially for beginners. Don't worry, though – our PHP generator gives you a jump-start by creating a fully functional PHP form script you can download and use without any PHP code knowledge.
To get the PHP contact form script for a simple contact form with Submit button, just click here and save the file, or copy the PHP contact form code from the window to the right.
Want to learn even more about PHP code? Check out our guide to building jQuery Contact forms with Ajax and PHP.
Use our PHP generator to create a PHP contact form with two parts: the form that visitors see and the PHP script that processes the form data and sends it where you want it to go. Each part of the form can be located in the same file (as you see in the PHP example script) or in two different files. To create a PHP file, you can copy and paste the demo code above or download the example code file we've provided.
2. Copy the PHP script from above
To gather user data, we'll create a simple PHP contact form that asks for a name, email and message (see above). We've highlighted the PHP contact form code above so you can see how it works.
When your visitors open the page with the form (see a live demo), they'll see the form fields from the HTML code. After filling out the form and clicking the 'Send email' button, visitors will stay on the same page but see a message confirming the form was processed. Submitting the form sets a hidden parameter called 'action' that prevents the form from being displayed again, so you won't bother visitors with forms they've already filled out. The form also uses PHP validation to ensure that all the HTML form fields are filled in properly. If even one required field is left empty, it generates an error message.
Create advanced forms with our PHP web form builder
This page shows you how to create a simple PHP contact form, which is pretty easy. If you want to gather more data with other types of fields, such as single-choice, multiple-choice, text box, a radio button, HTML tag or dropdown fields, you'll have to add validation and processing for these fields as well. Never fear, it’s easy and you don’t have to write the PHP form code — we generate it for you.
Ensure safety and accuracy of data
If spammers start to autofill your contact form with garbage data, you can add CAPTCHA image verification to stop them. If users mistype their email addresses, turn on form validation to make sure that all emails are formatted properly. And if you want your visitors to send you files, you can let them upload files with PHP code, too.
Doing all of this on your own would require advanced knowledge of PHP, but the 123FormBuilder free PHP contact form generator includes these features and many more to make form building a breeze. Give it a try today!
Ready to use templates
Select the type of form you need for your business from the list below or browse through our complete web form templates collection.
Add this PHP contact form template to your website and get messages sent directly to your inbox. Modify this contact form template easily, no programming skills needed!
Use this template
Use the PHP sales lead form to generate leads and prospects for your business. Modify this lead form template with ease and publish it on your website.
Use this template
Simplify the communication between your customers and your support team by sharing this support request form on your website.
Use this template
Sign up, get your own PHP contact form and publish it on the web.
So I finally managed to get my jquery/ajax contact form with the Google reCAPTCHA v2 to work, but if the reCAPTCHA isn't entered or invalid, the form is cleared, so the user would have to enter everything again. The also reCAPTCHA takes extremely long to load, so maybe it can be overlooked easily. How can I prevent it from clearing the form?
I found some solutions that place some php code in the value of the input fields, and something about htmlentities that I didn't quite understand, but I would like the page with the form to remain a .html file. Is it still possible to prevent it from clearing the form, or do I need to make my .html file a .php file?
Here is my form:
And here is the mailer.php that is called by the form:
And here is the app.js that goes with the form:
I would really appreciate your help!
user3504783user3504783
1 Answer
Your reCaptcha cases in PHP are working fine and returning success responses. That's the reason its calling .done() method on $.ajax()
And
Try adding some error headers like http_response_code(400); to both of them