Trium918 Posted May 5, 2007 Share Posted May 5, 2007 Problem: I am trying to prevent the user from accessing certain pages if they are not logged in. The user will be redirected to the login page if there is an attempt. The below code is what I have for members.php page and so far it works. What if the user tries to access the edit_profile.php directly. There's the problem. I am not able to get the redirect to work inside of the edit_profile page. When user enters edit_profile.php in the url it should redirect to login.php Edit_Profile.php <?php function displayLogin(){ global $logged_in; if($logged_in){ echo "<h1>Logged In!</h1>"; echo "Welcome <b>$_SESSION[username]</b>, you are logged in. <a href=\"logout.php\">Logout</a>"; } else { header("Location: login.php"); } } ?> Link to comment https://forums.phpfreaks.com/topic/50164-help-with-redirect-weigh-in-please/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.