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 2 of 2
  1. #1
    Senior Coder
    Join Date
    Aug 2005
    Posts
    1,119
    Thanks
    2
    Thanked 1 Time in 1 Post

    if, if, else, if, else, else...error?

    This is pretty much what i want to do:

    PHP Code:
    if ($username == $adminuser);
            {
                if (
    $password == $adminpass);
                    {
                        include 
    'admin/adminstart.php';
                    }
                    else
                    {
                        echo 
    $loginerror;
                    }
            }        
            else
            {
                echo 
    $loginerror;
            } 
    However i don't think this is the easiest way to do so. Im also getting errors. If someone can tell me the easiest way to do the same thing, i would be very happy. Thanks in advance!

    *edit added below*
    Im thinking maybe something like:
    PHP Code:
    if ($username == $adminuser) and ($password == $adminpass);
            {
                include 
    'admin/adminstart.php';
            }
            else
            {
                echo 
    $loginerror;
            } 
    but im getting the and statment wrong.
    Last edited by thesavior; 01-04-2006 at 05:09 AM.

  • #2
    Regular Coder
    Join Date
    Aug 2004
    Location
    The US of A
    Posts
    767
    Thanks
    1
    Thanked 0 Times in 0 Posts
    Close. There is a few errors in your code. The most obvious is the semicolon after the if statements, there doesn't need to be one. And your "fixed" code was close, an if statement needs to be completely enclosed in parentheses. You can also use the and keyword of the double ampersand (&&) for this.

    PHP Code:
    if ($username == $adminuser && $password == $adminpass)
            {
                include 
    'admin/adminstart.php';
            }
            else
            {
                echo 
    $loginerror;
            } 


  •  

    Posting Permissions

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