I was using the PHP contact form that I download from CSS Tricks. When the user clicks submit in Opera or Chrome it submits the form even if the text fields are blank -
Thanks for the relpy. That makes sense but I am not so versed with PHP, so I am not sure how to get the code to work. Could you help me with getting the validation to work?
Anyway - thanks for the help - if you have time, I have a style quesiton - When the warning happens is there a way to create that on the same page or at least a pop up -
Anyway - thanks for the help - if you have time, I have a style quesiton - When the warning happens is there a way to create that on the same page or at least a pop up -
John
Hey ponyack,
You would either have to use JavaScript to validate the fields (but if JS is disabled, that will fail) or you're going to have to use AJAX to check for the PHP reply and show it on the screen. Both of which I don't have much experience in :p
I was using the PHP contact form that I download from CSS Tricks. When the user clicks submit in Opera or Chrome it submits the form even if the text fields are blank -
Any help with this would be appreciated
John
if(empty($_POST['name']) || empty($_POST['email']) || empty($_POST['comments'])){//run code here
die()
} else {
//continue with validation
}
That basically says "if a field is empty, run code & die (stop processing), else continue with validation"
Thanks for the relpy. That makes sense but I am not so versed with PHP, so I am not sure how to get the code to work. Could you help me with getting the validation to work?
Below is the code that I am using right now
John
That should work. It is untested, but try it and get back to me.
That works great.
I just realized that the PHP form has a bunch of JavaScript that is supposed to do the validation.
This is a link - its the second form http://css-tricks.com/downloads/php-stuff/
Anyway - thanks for the help - if you have time, I have a style quesiton - When the warning happens is there a way to create that on the same page or at least a pop up -
John
Hey ponyack,
You would either have to use JavaScript to validate the fields (but if JS is disabled, that will fail) or you're going to have to use AJAX to check for the PHP reply and show it on the screen. Both of which I don't have much experience in :p
Thanks for the help, I have found another PHP script that does a good job of validation.
John