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
    New to the CF scene
    Join Date
    Feb 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Small Problem regarding login script.

    Hello,

    Just wondering if I could pick your brains about a problem I'm having:

    Its a simple login script which basically shows admin (1) a seperate page to that of a user (0).

    So far I've got it to recognize isadmin 0 and take you to one page but even if you login as a user it still shows the same text "Hello, you are an admin." etc

    Please help

    Regards,
    Dan


    Code:
    <?php 
    //connect to db
    $conn = mysql_connect("localhost", "blah", "blah") or die(mysql_error());
    mysql_select_db("blah") or die(mysql_error());
    
    //declares variable
    $username=$_POST["username"]; 
    $password = $_POST["password"];
    $isadmin = $_POST["isadmin"];
    
      $result = mysql_query ("SELECT * FROM users WHERE username = '$user' AND password = '$password'");
      $q = mysql_query ("SELECT * FROM users WHERE isadmin = '$isadmin'");
      
      if(mysql_num_rows($q)==1){ 
         echo ("Hello, you are an admin. Click<a href=\"index.php/\">here to go back home</a>");
    	 
      }
      
       else if(mysql_num_rows($q)==0){  
         echo "Hello Normal user."; 
       
    }
    ?>

  • #2
    New to the CF scene
    Join Date
    Feb 2010
    Location
    CPU
    Posts
    9
    Thanks
    0
    Thanked 0 Times in 0 Posts
    isadmin is a field in user table so the first query of urs will return isadmin field then check the isadmin field using an if condition


  •  

    Posting Permissions

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