Reply
self requesting page displays validation error messages before user has cliced submit
Old 06-16-2008, 05:04 PM self requesting page displays validation error messages before submit is clicked
drew22299's Avatar
Skilled Talker

Posts: 91
Location: Wiltshire, UK
Hi,

I have a contact form that uses $_SERVER['PHP_SELF'] when the user clicks the submit button which works ok, but the validation messages/checks are exectuted even before the user has clicked the submit button.

Why is this?

Thanks,
__________________
www.hotlista.co.uk

Last edited by drew22299 : 06-16-2008 at 06:15 PM.
drew22299 is offline
Reply With Quote
View Public Profile Visit drew22299's homepage!
 
When You Register, These Ads Go Away!
Old 06-16-2008, 05:43 PM Re: self requesting page displays validation error messages before user has cliced su
PeachyJuice's Avatar
Skilled Talker

Latest Blog Post:
One Month Progress Report
Posts: 94
Name: Michele T.
Location: Ny, Ny
You probably don't have your code in a conditional statement? Otherwise everything will get executed.

What I usually do is have the user submit the form and then write any errors to a variable which I call $error.
PHP Code:
<?php if(isset($_POST['submit'])){
//validate the form stuff
}
if(!isset(
$_POST['submit']) || isset($error)){
//display the form, use sticky values to keep important stuff if there's an error
}
?>
__________________
Freelance web+graphic designer and PHP developer.
Web Design Portfolio
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 06-16-2008, 06:14 PM Re: self requesting page displays validation error messages before user has cliced su
drew22299's Avatar
Skilled Talker

Posts: 91
Location: Wiltshire, UK
Thanks for the error suggestion It didn't work because I wasn't checking the correct $_POST element, I changed it to 'submit' and it worked.

Thanks,
__________________
www.hotlista.co.uk
drew22299 is offline
Reply With Quote
View Public Profile Visit drew22299's homepage!
 
Reply     « Reply to self requesting page displays validation error messages before user has cliced submit
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.11269 seconds with 12 queries