logging in on an account on a webpage - SQL and php

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jimiwa
Forum Newbie
Posts: 3
Joined: Sat Oct 31, 2009 2:42 pm

logging in on an account on a webpage - SQL and php

Post by jimiwa »

I'm working on a website where I'm designing a interactive
website kind of social-networking style where users
create an account, can post discussions on boards,
and create their own mini-websites within the main website,
and having other various interactive stuff.

I'm just starting on the basics as I haven't worked much with php
before even though I've had quite a few years of non-professional
programming practice.

I have it so that the user types in name, username, and password
and then the user is sent an email to validate the account. I
have it so that a validation email is sent and the user then validates
the account, where the sql database "validated" variable is set
to true.

Haven't gotten past this point, but I'm wondering, how do I have
a user log in, and exactly how does my website know that the user
is logged in when he or she moves from page to page on the website,
and how does my website know when that person is logged out?
User avatar
AbraCadaver
DevNet Master
Posts: 2572
Joined: Mon Feb 24, 2003 10:12 am
Location: The Republic of Texas
Contact:

Re: logging in on an account on a webpage - SQL and php

Post by AbraCadaver »

You log them in by checking their username and password in the database. You would then use sessions that persist variables across pages. You could set a session var with their userid and then check to see if that is set on other pages to see if they are logged in or not. To log them out, you destroy the session and unset the session vars.
mysql_function(): WARNING: This extension is deprecated as of PHP 5.5.0, and will be removed in the future. Instead, the MySQLi or PDO_MySQLextension should be used. See also MySQL: choosing an API guide and related FAQ for more information.
Post Reply