admin panel login

helo . i am crating an admin panel login… if the your is admi then it will open the signup page … if user is other then it will open some other page and if pasword is wrong it shall display wrong pasword… i had created the code . but i find some syntax error … please help me

<?php if(isset($_POST['btnSubmit']) ) { $val = $Tblsignup->selectpass($_POST['uname'],$_POST['pass']); if ($val =='1'){ if($_POST['uname'] == 'admin'){ echo "Welcome! Admin Thanks for Login"; redirect("index.php?page=signup"); } } else { echo "Welcome! Thanks for Login"; redirect("index.php?page=grid.php"); } } else { echo "WRONG USER"; redirect("index.php?page=login.php"); the coding is working for admin. and for wrong pasword, but not for any other username

What is the syntax error, is this all of the code?

250,

It would be handy if you also mention the syntax error you get :wink:

Anyway. I think you have an ‘else’ on a wrong level

You want:

[PSEUDOCODE]
IF ( btnsubmit )
{   IF ( successful login  )
    {   IF ( uname == 'admin' )
        {   // Serve the admin pages
        } else
        {   // Serve the user pages
        }
    } else
    {   // Tell the user the login went wrong
    }
}   

You do:

[PSEUDOCODE]
IF ( btnsubmit )
{   IF ( successful login )
    {   IF ( uname == 'admin' )
        {   // Serve the admin pages
        }
    }  else
    {   // Serve the user pages
    }
} else
{   // Tell the user the login went wrong
}   

Is that correct?
Hope it helps, ;D
O.

Sponsor our Newsletter | Privacy Policy | Terms of Service