Jump to content

Page To Page Remember Login


phplearner696

Recommended Posts

Hi Everybody

Im 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\" /]
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

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.
Link to comment
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.