View Full Version : not validating the value
mivec
03-22-2004, 06:54 PM
hi all...u see...i was doing an if-else so that i can different stuff in difference conditions. here is the code for the ifelse:
<? if (($_POST["selNameFirst"] == 'Bride') && ($_POST["selNametype"] == 'First Names Only')) {
statements
.
.
.
}
elseif (($_POST["selNameFirst"] == 'Groom') && ($_POST["selNametype"] == 'First and Last Name')) {
statements.
.
.
.
}
else{
echo("error");
}
i know it's long...but if someone can help me in this i am really greatfull. the problem here is that whenever i click the send button from the previous page, the if and elseif statements kjust doesn't seem to be processed and hence the it goes to the 'echo("error");' part. is my syntax wrong?i have been starring at this prob since 2 hours ago.pls help.thank you thank you
sad69
03-22-2004, 07:49 PM
Instead of using == to check equality of strings, I use the strcmp() function.
if (strcmp($_POST["selNameFirst"], 'Bride') == 0 && strcmp($_POST["selNametype"], 'First Names Only') == 0)
Hope that makes sense and helps,
Sadiq.
I don't see anything wrong with the code.
Using == is fine a,d it will probably not be what is causing the problem. I don't see any reason to use strcmp(), which will probably be slower.
Did you echo out the variables before the comparisons ?
echo $_POST["selNameFirst"] . '<br />' . $_POST["selNametype"] ;
mivec
03-22-2004, 08:27 PM
raf,
is it ok that i can interact with u tru a chat messenger?or email prehaps?i am totally lost here...and my code is too long to post here.if it's ok with u, can i have ur email address or msn messenger chat?i have yahoo & msn messenger and walso icq.
pls hepl me.it's very urgent.thank you a million
you can use the mail function in this forum. Send me the form and processing code
or attach a zipfile here with them her, if they don't contain sensitive data/secret code
i'll contact you if necessary, but you'll get better/faster help by posting here.
mivec
03-22-2004, 08:35 PM
ok raf....i am attaching a zip file here. i hope u can help me.thakns a zillion.
Nightfire
03-22-2004, 09:33 PM
In your form, you have the following:
<SELECT
style="FONT-SIZE: 8pt;
COLOR: #000000;
FONT-FAMILY: 'Verdana';
BACKGROUND-COLOR: #ffffff"
name=selNameFirst>
<OPTION value=B
selected>Bride</OPTION>
<OPTION
value=G>Groom</OPTION>
</SELECT>
You should change the value to what you're matching, ie change value=B to value=Bride
It appears you've done the same all through your code. In the php you're matching the value, not what is shown. So for example
<select name="yaks">
<option value="1">Foo</option>
<option value="2">Bar</option>
</select>
Won't match up with
<?php
if($_POST['yaks'] == "Foo"){
do stuff
?>
But it would work if you either changed the Foo's value to Foo, or changed the php to look for 1 instead.
Hope that makes sense
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.