Jump to content

If username = admin


DYWBH

Recommended Posts

I am trying to make it so if the admin user logs in it directs them to the admin page. I am using sessions.

 

<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$userid = $_SESSION['userid'];
$username = $_SESSION['username'];
?>

 

Here is the code i'm using:

if ($username = 'admin'){
header("Location: ./admin.php");
}
else

 

However, it is directing to the admin.php page even if you aren't the admin or even if youre not logged in! What's wrong with my code?

 

Also, is this the best way to go around having an admin page? What other ways would you suggest?

 

Thanks

Link to comment
https://forums.phpfreaks.com/topic/239928-if-username-admin/
Share on other sites

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.