ananaz Posted December 26, 2010 Share Posted December 26, 2010 Hello Im trying to make a php that only will be accessible for a specific user for example "admin" <?php session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } else { if(!myusername == 'admin'){ header("location:index.php"); } else { echo "Välkommen ". $_SESSION['user']; } } ?> index.php is the mainpage you get thrown back to if session is not registered or if myusername isn't admin (tho it doesn't work) Link to comment https://forums.phpfreaks.com/topic/222675-access-php-with-specific-username/ Share on other sites More sharing options...
mmarif4u Posted December 26, 2010 Share Posted December 26, 2010 Your code: <?php session_start(); if(!session_is_registered(myusername)){ header("location:index.php"); } else { if(!myusername == 'admin'){ header("location:index.php"); } else { echo "Välkommen ". $_SESSION['user']; } } ?> session_is_registered is deprecated. Now new version for your script: <?php session_start(); if(!$_SESSION['myusername']){ header("location:index.php"); } else { if($_SESSION['myusername'] != 'admin'){ header("location:index.php"); } else { echo "Välkommen ". $_SESSION['myusername']; } } ?> Link to comment https://forums.phpfreaks.com/topic/222675-access-php-with-specific-username/#findComment-1151568 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.