View Full Version : not validating the value

03-22-2004, 07: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')) {
elseif (($_POST["selNameFirst"] == 'Groom') && ($_POST["selNametype"] == 'First and Last Name')) {

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

03-22-2004, 08: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,

03-22-2004, 08:55 PM
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"] ;

03-22-2004, 09:27 PM
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

03-22-2004, 09:30 PM
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.

03-22-2004, 09:35 PM
ok raf....i am attaching a zip file here. i hope u can help me.thakns a zillion.

03-22-2004, 10:33 PM
In your form, you have the following:

style="FONT-SIZE: 8pt;
COLOR: #000000;
FONT-FAMILY: 'Verdana';
<OPTION value=B

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>

Won't match up with

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