tecmeister Posted April 1, 2008 Share Posted April 1, 2008 Hi everyone, I would like to make a few pages for members access only. What is the script that i need to use? Thanks for the help, tecmeister Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/ Share on other sites More sharing options...
MadTechie Posted April 1, 2008 Share Posted April 1, 2008 What is the script that i need to use? a Members only access script should do it.. Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506948 Share on other sites More sharing options...
tecmeister Posted April 1, 2008 Author Share Posted April 1, 2008 Well yeah i new that. But i dont know what the members access only script is. Sorry for the misunderstanding. Do you know what the members only access script is? Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506952 Share on other sites More sharing options...
MadTechie Posted April 1, 2008 Share Posted April 1, 2008 its a script that only allows members into an area.. okay on your login section you probably set a session, ie <?php session_start(); $_SESSION['UserID'] = 10;//the user id Logout removes its <?php session_start(); $_SESSION['UserID'] = 0;//the user id session_destroy(); members only checks it <?php session_start(); if(empty($_SESSION['UserID'])); { die("No access, please login first"); } echo "welcome"; Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506956 Share on other sites More sharing options...
tecmeister Posted April 1, 2008 Author Share Posted April 1, 2008 It is saying: No access, please login first The login part in on my index.html then it goes to checklogin.php then goes to index.php I put nothing in the first page. Then i put on checklogin: <?php session_start(); $_SESSION['UserID'] = 10;//the user id ?> And on index.php i put: <?php session_start(); if(empty($_SESSION['UserID'])); { die("No access, please login first"); } echo "welcome"; ?> Is there somthing that i have done wrong? Much appreciated for you help. Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506967 Share on other sites More sharing options...
MadTechie Posted April 2, 2008 Share Posted April 2, 2008 would probably need to see more of the code, but i am off to bed.. check that session_start(); is at the start of the code. if you go back to my last post and create 3 files login.php, members.php & logout.php with their code and then goto members.php (it should fail) then login.php then back to members.php (should load) you say you put the members.php code on the index.php page.. does this page check the login? if so you should have another page to login, and a different page for members only (well for this example anyway) Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506977 Share on other sites More sharing options...
KMLT Posted April 2, 2008 Share Posted April 2, 2008 you need to set the Session id to 10.. Make a form with username and password, and a submit button. and then make a code that checks if the username and password is right, and then sets the session id to 10.. Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506981 Share on other sites More sharing options...
shortj75 Posted April 2, 2008 Share Posted April 2, 2008 you could try session_start(); if (isset($_SESSION['user'])) { page code here } else { echo "SORRY YOU ARE AUTHORIZED TO VEIW THIS SITE!!!"; } this is the code i use and it works good Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-506989 Share on other sites More sharing options...
tecmeister Posted April 2, 2008 Author Share Posted April 2, 2008 Thanks bud the script works. Much appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/99076-solved-members-access-only-help/#findComment-507053 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.