allcamchat Posted May 29, 2010 Share Posted May 29, 2010 I am attempting to block certain pages of my site to registered members only. I'm new to php and a college student. My site is www.allcamchat.com , could someone give me advice on how to do this simply. As you can see I already have join and login generated. I did that on my own. Just not sure if it would be an include once or what for like My Matrix. Thank you all for time spent on me. Also I work on a very limited budget, so downloading random programs wouldn't be an answer. AllCamChat Quote Link to comment https://forums.phpfreaks.com/topic/203291-members-only/ Share on other sites More sharing options...
-Karl- Posted May 29, 2010 Share Posted May 29, 2010 Since you have a database, with registered users and a login form, all you need to do is create a function to make sessions when a user logs in sucessfully. Quote Link to comment https://forums.phpfreaks.com/topic/203291-members-only/#findComment-1065089 Share on other sites More sharing options...
jcbones Posted May 29, 2010 Share Posted May 29, 2010 Log in Process session_start(); if(isset($_POST['login'])) { $user = mysql_real_escape_string(strip_tags($_POST['login'])); $sql = "SELECT * FROM `users` WHERE `username` = '$user'"; $result = mysql_query($sql); if(mysql_num_rows($result) == 1) { $_SESSION['loggedin'] = 1; } else { $_SESSION['loggedin'] = 0; } } function protectPage() { if($_SESSION['loggedin'] == 1) { return; } else { header('Status: 200'); header('Location: http://mysite.com/login.php'); exit(); } return; } Protected Page <?php session_start(); protectPage(); ?> Or, something along those lines. Quote Link to comment https://forums.phpfreaks.com/topic/203291-members-only/#findComment-1065090 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.