Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question not validating the value

    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:

    PHP Code:
    <? 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
    Warm Regards,
    Mivec

  • #2
    Senior Coder
    Join Date
    Feb 2004
    Posts
    1,206
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Instead of using == to check equality of strings, I use the strcmp() function.

    PHP Code:
    if (strcmp($_POST["selNameFirst"], 'Bride') == && strcmp($_POST["selNametype"], 'First Names Only') == 0
    Hope that makes sense and helps,
    Sadiq.

  • #3
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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"] ;
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #4
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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
    Warm Regards,
    Mivec

  • #5
    raf
    raf is offline
    Master Coder
    Join Date
    Jul 2002
    Posts
    6,589
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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.
    Posting guidelines I use to see if I will spend time to answer your question : http://www.catb.org/~esr/faqs/smart-questions.html

  • #6
    Regular Coder
    Join Date
    Feb 2004
    Location
    Malaysia
    Posts
    175
    Thanks
    0
    Thanked 0 Times in 0 Posts
    ok raf....i am attaching a zip file here. i hope u can help me.thakns a zillion.
    Attached Files Attached Files
    Warm Regards,
    Mivec

  • #7
    Senior Coder Nightfire's Avatar
    Join Date
    Jun 2002
    Posts
    4,265
    Thanks
    6
    Thanked 48 Times in 48 Posts
    In your form, you have the following:
    Code:
    <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
    Code:
    <select name="yaks">
        <option value="1">Foo</option>
        <option value="2">Bar</option>
    </select>
    Won't match up with
    PHP Code:
    <?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


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •