phplearner696 Posted June 14, 2006 Share Posted June 14, 2006 Hi EverybodyIm a guy learning php and making my own website at the same time. I have some knowledge of databases, MySQL, php and lots of HTML knowledge. Now to the point I am trying to create my own loging script and i am getting there but i cant figure out how to make each page require a login and recocnize the fact that the person is logged in at all. I have a script that registers users, logs them in and even sends them there forgoten password but without a script to make each page know wheather or not the user is logged in I'd have to have a login page before everything, and who would want to login evertime they did anything at my site. Please help me I know i need to use cookies of some sort but I dont know how. If you like you can email me directly at gordon@dcdata.ca. [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/unsure.gif\" style=\"vertical-align:middle\" emoid=\":unsure:\" border=\"0\" alt=\"unsure.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/huh.gif\" style=\"vertical-align:middle\" emoid=\":huh:\" border=\"0\" alt=\"huh.gif\" /] [img src=\"style_emoticons/[#EMO_DIR#]/excl.gif\" style=\"vertical-align:middle\" emoid=\":excl:\" border=\"0\" alt=\"excl.gif\" /] Quote Link to comment https://forums.phpfreaks.com/topic/11999-page-to-page-remember-login/ Share on other sites More sharing options...
trq Posted June 14, 2006 Share Posted June 14, 2006 [!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--] I have a script that registers users, logs them in [/quote]How exactly does it log them in if your not sure how to persist this?You need to look into using sessions. There are many tutorials around for building a login system, and Im afraid from the description of your problem it sounds like you really need to read one. Quote Link to comment https://forums.phpfreaks.com/topic/11999-page-to-page-remember-login/#findComment-45651 Share on other sites More sharing options...
Atomg Posted June 14, 2006 Share Posted June 14, 2006 [!--quoteo(post=383921:date=Jun 14 2006, 02:03 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 14 2006, 02:03 PM) [snapback]383921[/snapback][/div][div class=\'quotemain\'][!--quotec--]You need to look into using sessions. There are many tutorials around for building a login system, and Im afraid from the description of your problem it sounds like you really need to read one.[/quote]Thorpe, I would like to know those websites. Well, tutorials that you think are good to make our own login system. Do you know any that are nice?Thanks a lot. Quote Link to comment https://forums.phpfreaks.com/topic/11999-page-to-page-remember-login/#findComment-45733 Share on other sites More sharing options...
wisewood Posted June 15, 2006 Share Posted June 15, 2006 in very basic terms, as i'm a bit pressed for time.have your html form processed by a php script which compares the username and password to records in the database, if there is a match for that username and password combination, set the session variable for the username to the same as the username they input onto the form.eg. $_SESSION[username] = $_POST[username];Once this is done, you just add something like this to the pages you want to make available only to people who are logged in.if(!$_SESSION[username]) { echo "You're an imposter!!!"; }else {// Your page code here}That will give you a simple login system. You can fill it out later with authorisation levels and stuff so you can show some content to "admin" and less to "users" etc. Quote Link to comment https://forums.phpfreaks.com/topic/11999-page-to-page-remember-login/#findComment-45842 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.