Jump to content

Archived

This topic is now archived and is closed to further replies.

phplearner696

Page To Page Remember Login

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\" /]

Share this post


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

Share this post


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

Share this post


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

Share this post


Link to post
Share on other sites

×

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.