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) Quote Link to comment 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']; } } ?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.