Jump to content

simple admin logon and redirect


ntroycondo

Recommended Posts

I am creating a (my first  )very simple php/mysql application.

This is probably a very basic question. Any and all help is thanked in advance.

 

I have a working login script but want to make it better by having specific static 'admin' username redirect to a different page than any other username in the DB.

 

So i need my $username==admin to do something besides just echo some text back.

 

Here's what i currently have in place:

 

if ($username==$dbusername&&$password==$dbpassword)

{

echo "Welcome!";

}

else

echo "Incorrect password!";

}

else

die("User does not exist");

 

Link to comment
https://forums.phpfreaks.com/topic/205386-simple-admin-logon-and-redirect/
Share on other sites

  $getuser="SELECT * from pf_table where username='$user' and password='$password'";
  $getuser2=mysql_query($getuser) or die(mysql_error());
  $getuser3=mysql_fetch_array($getuser2);
  if($getuser3)
  {
    $_SESSION['username']=$_POST['username'];
  if($getuser3['username'] == "admin")
  {
header ("Location: http://www.domain.com/admin.php");
} else {
echo "Welcome user!":
}
} else {
echo "Invalid Password":
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.