form validation

 
Post new topic   Reply to topic    Aprelium Forum Index -> PHP
View previous topic :: View next topic  
Author Message
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Sun May 16, 2004 1:21 pm    Post subject: form validation Reply with quote

<?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 View user's profile Send private message MSN Messenger
TRUSTAbyss
-


Joined: 29 Oct 2003
Posts: 3752
Location: USA, GA

PostPosted: Sun May 16, 2004 7:18 pm    Post subject: Reply with quote

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 View user's profile Send private message Visit poster's website
iNaNimAtE
-


Joined: 05 Nov 2003
Posts: 2381
Location: Everywhere you're not.

PostPosted: Sun May 16, 2004 7:19 pm    Post subject: Reply with quote

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 View user's profile Send private message Send e-mail Visit poster's website AIM Address Yahoo Messenger MSN Messenger ICQ Number
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Tue May 18, 2004 7:07 am    Post subject: Reply with quote

right, thanks fellows..havent been checking my pc for awhile...will let u guys know if your solutions help
Back to top View user's profile Send private message MSN Messenger
jonleow
-


Joined: 29 Apr 2004
Posts: 48

PostPosted: Tue May 18, 2004 10:47 am    Post subject: Reply with quote

it worked..thanks
Back to top View user's profile Send private message MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> PHP All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group