Jump to content

simple athentication script


prezident

Recommended Posts

i already have the front page that calls the script, but its not letting me login, i don't see the problem i know its returning the rows from the database but i don't understand why its not letting me login and when i do get it to login messing around with the code everybody logs in as an admin, my database has, user, pass, and role inside admin, poweruser, and reg user but when i get it to log in everybody logs in as an admin, can someone please help me ? i even tried the error thing but that doesn't seem to work either

 


ini_set('display_errors', 1);
error_reporting(E_ALL);
//echo ini_set('display_errors');

session_start();

$username = $_POST['username'];
$password = $_POST['password'];

if (mysql_connect("localhost", "root", ""))
    {
        //echo 'connect';    
    }
    
else
    {
        echo 'failure';
    }

if  (mysql_select_db("athentication"))
    {
        //echo 'connect';    
    }
    
else
    {
        echo 'no connect';
    }

    $result = mysql_query("SELECT * FROM login WHERE user = '$username'");
    $rows = mysql_num_rows($result);
    $role = $rows['role'];

if ($rows != 0)
{
    if ($role == 'admin')
           {
           header('Location: admin.php');
           $_SESSION['username'] = $username;
           }
           
    elseif ($role == 'poweruser')
           {
           header('Location: poweruser.php');
           $_SESSION['username'] = $username;
           }
           
    /*elseif ($role ==' reg')
           {
            echo "WHAT UP";
            $_SESSION['username'] = $username;
           }*/
}
else
    echo "enter a valid user name";




Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.