Jump to content


Photo

Page To Page Remember Login


  • Please log in to reply
3 replies to this topic

#1 phplearner696

phplearner696
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 14 June 2006 - 05:55 PM

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

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 14 June 2006 - 06:03 PM

[!--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.

#3 Atomg

Atomg
  • New Members
  • Pip
  • Newbie
  • 9 posts

Posted 14 June 2006 - 10:37 PM

[!--quoteo(post=383921:date=Jun 14 2006, 02:03 PM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Jun 14 2006, 02:03 PM) View Post[/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.

#4 wisewood

wisewood
  • Members
  • PipPipPip
  • Advanced Member
  • 226 posts
  • LocationRotherham, England

Posted 15 June 2006 - 09:39 AM

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.
wisewood: proven fact, I am both wise, and wooden.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users