NameSilo

Help with a small Php login form

Spaceship Spaceship
Watch

TWM

Web Marketing SpecialistEstablished Member
Impact
9
I have

Code:
<?
$adminuser = "admin";
$clientuser = "client";
$adminpass = "admin";
$clientpass = "client";
if ($user == $adminpass&&$pw == $adminpass || $user == $clientuser&&$pw == $clientpass)
{
   header("Location: http://my-website.com/partner_area/partner_area.php");
}
  else
{
   print("Wrong username or password. Please try again.");
}
?>

How can i alter this so that if admin logs in, it takes him to admin area, and if client logs in, it takes them to client area.
 
0
•••
The views expressed on this page by users and staff are their own, not those of NamePros.
.US domains.US domains
Code:
<?
$adminuser = "admin";
$clientuser = "client";
$adminpass = "admin";
$clientpass = "client";
if ($user == $adminpass&&$pw == $adminpass)
{
   header("Location: http://my-website.com/partner_area/admin_area.php");
}
  else
{
   print("Wrong username or password. Please try again.");
}
if ($user == $clientuser&&$pw == $clientpass)
{ 
   header("Location: http://my-website.com/partner_area/client_area.php");
}
  else
{
   print("Wrong username or password. Please try again.");
}
?>
 
0
•••
Try this:

Code:
<?
$adminuser = "admin";
$clientuser = "client";
$adminpass = "admin";
$clientpass = "client";
if ($user == $adminpass&&$pw == $adminpass || $user == $clientuser&&$pw == $clientpass)
{
   if( $user == $adminuser ) {
    header( "Location: adminareaurl");  
    }
    else {
   header("Location: http://my-website.com/partner_area/partner_area.php");
   }
}
  else
{
   print("Wrong username or password. Please try again.");
}
?>
 
0
•••
nvm fixed it
 
Last edited:
0
•••
I just checked his code, and it works fine. Perhaps you had a copy error?
 
0
•••
Not sure, but i altered it and it works. I have 6 different usernames/passwords, they all are working great!
 
0
•••

We're social

Unstoppable Domains
Domain Recover
DomainEasy — Payment Flexibility
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back