View previous topic :: View next topic |
Author |
Message |
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Sun May 16, 2004 1:21 pm Post subject: form validation |
|
|
<?php
if (($sender_name =="") || ($sender_email=="") || ($comment =="")) {
header("Location: http://127.0.0.1/feedback.php");
exit;
}
the script above is my validation script for missing form fields. however it just redirects the users back to the feedback form page without indicating which are the fields they didnt complete. is there a way to do this? |
|
Back to top |
|
 |
TRUSTAbyss -
Joined: 29 Oct 2003 Posts: 3752 Location: USA, GA
|
Posted: Sun May 16, 2004 7:18 pm Post subject: |
|
|
I setup my form handling like this !
Code: |
<?php
if ($sender_name || $sender_email || $comment) {
print "Thank you For the feedback !";
}else{
print "Please make sure you filled in all required fields!";
}
?>
|
Your updated code for your's should look like
Code: |
<?php
if (($sender_name =="") || ($sender_email=="") || ($comment =="")) {
print "Fill Out All Required Fields !";
}else{
header ("Location: feedback.php");
exit;
}
?>
|
Last edited by TRUSTAbyss on Sun May 16, 2004 7:23 pm; edited 4 times in total |
|
Back to top |
|
 |
iNaNimAtE -
Joined: 05 Nov 2003 Posts: 2381 Location: Everywhere you're not.
|
Posted: Sun May 16, 2004 7:19 pm Post subject: |
|
|
You can do something like:
Code: | <?php
if ($sender_name =="")
echo "Please fill in your name";
?> |
(I might have screwed the syntax a bit, so I'll just call it half-pseudo code). _________________ Bienvenidos! |
|
Back to top |
 |
 |
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Tue May 18, 2004 7:07 am Post subject: |
|
|
right, thanks fellows..havent been checking my pc for awhile...will let u guys know if your solutions help |
|
Back to top |
|
 |
jonleow -
Joined: 29 Apr 2004 Posts: 48
|
Posted: Tue May 18, 2004 10:47 am Post subject: |
|
|
it worked..thanks |
|
Back to top |
|
 |
|