Jump to content

Members Only


allcamchat

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/203291-members-only/
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/203291-members-only/#findComment-1065090
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.