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 6 of 6
  1. #1
    TrainReq
    Guest

    running 2 ifs at once

    How do I run 2 ifs at once , but have the same else... for example

    If post password and if post email do query... if both of these or none of these are posted .. echo "Invalid"

  • #2
    Senior Coder shyam's Avatar
    Join Date
    Jul 2005
    Posts
    1,563
    Thanks
    2
    Thanked 163 Times in 160 Posts
    the boolean operator '&&'

  • #3
    Regular Coder goughy000's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    415
    Thanks
    0
    Thanked 0 Times in 0 Posts
    just combine them into one if

    PHP Code:
    <?php
    if($_POST['password'] == "correct password" && $_POST['email'] == "correct@email.com"){
       
    dostuff();
    }else{
       echo 
    "Invalid";
    }
    ?>


    EDIT: u beat my post by like 2 seconds
    Last edited by goughy000; 03-20-2007 at 11:57 PM. Reason: see post
    PHP Freelancing!
    ByteForums!
    Scriptlance.comNeed a job done quick? post it on scriptlance! OR! your a programmer? sign up and get paid for these jobs!

  • #4
    TrainReq
    Guest
    wat about && $_POST['email'] == "ANYTHING"

    BTW:
    Parse error: syntax error, unexpected T_BOOLEAN_AND in /home/nightse/public_html/sttest/login.php on line 5

    (just make sure email was posted period)
    Last edited by TrainReq; 03-21-2007 at 12:09 AM.

  • #5
    Senior Coder
    Join Date
    Jan 2007
    Posts
    1,648
    Thanks
    1
    Thanked 58 Times in 54 Posts
    Post the entire line you tried. Otherwise we can't see what went wrong.

  • #6
    Regular Coder goughy000's Avatar
    Join Date
    Nov 2005
    Location
    England
    Posts
    415
    Thanks
    0
    Thanked 0 Times in 0 Posts
    if you just want to check that an email was set and not that is is a certain value

    so thats dosnt = nothing and is set

    PHP Code:
    <?php 
    if($_POST['password'] == "correct password" && $_POST['email'] != "" && isset($_POST['email'])){ 
       echo 
    "ok";
    }else{ 
       echo 
    "Invalid"

    ?>
    your error sounds like you missed a ; earlier on in the script
    Last edited by goughy000; 03-21-2007 at 05:30 PM. Reason: cant spell
    PHP Freelancing!
    ByteForums!
    Scriptlance.comNeed a job done quick? post it on scriptlance! OR! your a programmer? sign up and get paid for these jobs!


  •  

    Posting Permissions

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