bobicles2 Posted March 9, 2010 Share Posted March 9, 2010 Ok so ive used some tutorials and spent some time and managed to get a very very simple log in script working fine, however, what i want to do now is learn how to take advantage of this for example...make it so only members who are logged in can do certain things on my site. My website is an events management site (similar to seetickets/ticketmaster) however, users can add there own events to the database, this feature works however, its available to ALL users i want to make it so only users who have logged into the site can use this feature i have no idea where to begin really, everyone here usually gives fantastic advice so any help is useful! thanks rob Link to comment https://forums.phpfreaks.com/topic/194615-log-in-script-help/ Share on other sites More sharing options...
aeroswat Posted March 9, 2010 Share Posted March 9, 2010 Ok so ive used some tutorials and spent some time and managed to get a very very simple log in script working fine, however, what i want to do now is learn how to take advantage of this for example...make it so only members who are logged in can do certain things on my site. My website is an events management site (similar to seetickets/ticketmaster) however, users can add there own events to the database, this feature works however, its available to ALL users i want to make it so only users who have logged into the site can use this feature i have no idea where to begin really, everyone here usually gives fantastic advice so any help is useful! thanks rob Depends on how they are logged in? You usually use a SESSION variable for this. So maybe check to see if the SESSION variable is set. Something including an authorization php file at the beginning of all of ur files that would have something like: if(!isset($_SESSION['MEMBER_USERNAME'] || $_SESSION['MEMBER_USERNAME'] == '') { echo "You don't have permission"; exit(); } Link to comment https://forums.phpfreaks.com/topic/194615-log-in-script-help/#findComment-1023639 Share on other sites More sharing options...
FYI_Geek Posted March 9, 2010 Share Posted March 9, 2010 I see no one replied to you yet so i though i would help you out. I assume you already created the users table in the db, do you use sessions when they login? If so you can do like i did: 1- Register new users, MD5 there passwords (for security) 2- Make the login page: and assign the sessions. 3- Add this to your member pages: ///////MEMBERS ONLY session_start(); //CHECK USER $_SESSION if($_SESSION['userid'] > 0) { $smarty->assign('user_logged', 1); } else { $smarty->assign('user_logged', 0); } ////^ The above is how i assign the Member/Guest menus. if($_SESSION['userid'] > 0) { PUT YOUR DATABASE INFO OR WHAT EVER EHRE... } else { $smarty->assign('user_logged', 0); header("Location: login.php$return_url"); } Just replace the &_SESSION with your member table names and' change the smarty to result or what ever you use. Hope that helps you, if not mail me i can help you build one from scratch if you need it. Link to comment https://forums.phpfreaks.com/topic/194615-log-in-script-help/#findComment-1023645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.