• 0

php page for members only


Question

hi i have a website and i have setup MySQL and all the other php and people can now login BUT i cant find how to make hidden pages for members to see and access can anyone help me???

<snip> - bmaher

Hey y am i not allowed to show people my website

Edited by bmaher
no warez links or discussion
Link to comment
https://www.neowin.net/forum/topic/650761-php-page-for-members-only/
Share on other sites

12 answers to this question

Recommended Posts

  • 0

You can use cookies or headers and check if its set or not.. bit of a better way then the above.

In your login script you would do

// form post data vars, etc..
session_start();
$sql = mysql_query("SELECT membername FROM table WHERE membername = '{$_POST['membername']}' AND password = '{$_POST['password']}'");
$rows = mysql_num_rows($sql);
if (isset($rows) &amp;&amp; $rows == 1) {
 session_register('username');
 $_SESSION['username'] = $_POST['membername'];
}

Then on the top of all your member only pages have

if (!isset($_SESSION['username'])) {
 header("index.php");
}
else {
 do what you want members to see
}

Logout being

if (isset($_SESSION['username'])) {
 session_unset();
 session_destroy();
 echo "Logged out";
} 
else {
 header("index.php");
}

  • 0

you're starting off on the wrong foot here, defying the rules and moderators' decisions by putting the link back is just going to end up getting you warned/banned, and rudeness isn't going to get you any help. the reason for the link being removed was not due to your post possibly coming across as looking like spam, as i previously speculated, but it seems because of the nature of the content of your website - it is against the rules to discuss or post links to warez. neowin community forum rules

let it go, and let's get back on topic, speaking of which, how did you get on with the solutions provided?

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.