Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

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

Posts: 93
Trades: 0
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,

Last edited by drew22299; 06-16-2008 at 05:15 PM..
drew22299 is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 06-16-2008, 04:43 PM Re: self requesting page displays validation error messages before user has cliced su
PeachyJuice's Avatar
Super Talker

Posts: 116
Name: Michele T.
Location: Ny, Ny
Trades: 1
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.

Please login or register to view this content. Registration is FREE
PeachyJuice is offline
Reply With Quote
View Public Profile
 
Old 06-16-2008, 05:14 PM Re: self requesting page displays validation error messages before user has cliced su
drew22299's Avatar
Skilled Talker

Posts: 93
Trades: 0
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,
drew22299 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to self requesting page displays validation error messages before user has cliced submit
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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

BB 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.38941 seconds with 12 queries