Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.