![]() |
Required fields in a contact form
I am making a contact form that needs required fields. I have it set for one field to be required, but when I try to make the other fields required I get a white page. Here is my code:
Code:
if (isset($_POST['submit'])) { |
You are using and commands in your if statement, thus it will not trigger unless all of them are empty. The blank screen is the script sending the mail.
|
Quote:
|
Ok I got the fields to be required by changing
Code:
if(!$name && !$email && !$message) {Code:
if(empty($name) || empty($email) || empty($message)) { |
There are a few ways, ajax could return an error message so the fields don't go blank, you could have the script post to itself so that you can fill the form with the posted data. Those are what I can think of off hand.
|
| All times are GMT. The time now is 12:32 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0