Part of the ‘Register & Login’ Project from PHP Academy. This tutorials walks you through how to process a username and password based login against details found in a database, set a session, and process a logout function.
PHP Tutorials: Register & Login: User login (Part 3)
June 21st, 2010
phpmoz 
Posted in
Tags: 

@mag1cwand
i have same problem. when i write session_start(); same problem :S
did you solved it?
is it possible to link directly to the member.php page when you successfully login rather than having to go through a link?
i don’t get it if i create username session then i cant display registred name (not username) on members page. Please help me:)
if you wanted users to be able to register, how would you do that?
thank you so much =) my first login page
oh man, you are amazing…do you know this?
@dashbyictfd hm nope that wasn’t my mistake… but i’ve solved it! i should’ve read all the comments before i posted this question… i had the “session_start” somewhere in the middle of the page… got it working now though!
THX!
@frichjof90 put opening an closin braces and the echo welcome in the middle
“else, im gonna want to die… not that i want to die, but the page is gonna want to die”
Win of a quote
Great tutorial, working for me!
I have a different question though…. everything works fine with me but in the member.php site or the logout.php site i get a “Warning” message blowing up because of the “session_start” function aparently. has anyone got an idea why that happens and what is wrong?! THX!
btw Alex, you’re brilliant! THX a lot!
@ComputerHelpz100
i do have! i had the same and my problem was the following:
Is your username all smal caps?! mine wasnt and if the username isn’t the same in the DB (remember it was changed to smal letters by “strtolowers”. so for e.g.
Frichjof is my username but in the DB it would be frichjof!
Add the “strtolower” in the login- $username and it should work! at least it did for me
Goooo00000OOOd joB!
You´ve probably fixed this already. But if others may have the same question.
An answer could be as simple as using a header.
If every requirements are meet e.g. the ELSE field where you would normaly get the the “Succes!” or “You´re in proceed to login page”… as this tutorial ends up with.
U´ve can simply write: header(“LOCATION:login.php”);
Hope this helps
Dude I totally love it… You´re doin a great job and helping a lot of lost soles as myself
)
Though I have one small inquiry…
Since you´ve made the registration with encrypted passwords it might be convenient to make the “log in” to recognize the encrypted passwords also!!!
I cant seem to make it work.
Much appreciated if you either could make a tutorial that explains it, or simply a small comment would be fine as well(you might be a busy man, after all
Would be most appriciated. TNX
Hi Alex ….. U r awsum …. the way u tel the things ,,, is amazing,.,,,,thanks a ton 4 helping meeeeeeeeeeeeeeeeeeeeeeeeeeeee
@ComputerHelpz100
just check to make sure your code matches his, but most importantly, make sure you user the dollar signs ($) before your variables.
if($username == $dbusername && $password == $dbpassword)
{
}
This is the statement which compares your username and password with the ones in the database. make sure all that is correct.
can u upload the source code ? i get a white page all the time
you are a legend!!!!!
It works almost fine but I do have one problem, when i test it it all works and when I enter the wrong password it displays Incorrect Password which is right but then when i enter the correct password it still displays Incorrect Password. has anyone got any idea what is going wrong??
ironboy is ur server running?
@Ironboy500 same.
Thanks a great deal Alex, love your tutorials.
Could you please make a tutorial on how to post comments on a website? like a fb type website? Thanks again
jowebsites@Ironboy500
Hey, I just followed the entire tutorial and got it to work, I can send u my files if you want. You’ll just have to change the HOST, USERNAME and PASSWORD in the INDEX.PHP file. Send me ur email if u want and I’ll attach them in a file and send them to u. I also learning php for the first time and I am glad I got it to work Are u some kind of web designer? I do a lot of HTML and CSS but that’s about it. I’m trying to deep my toes in php and js. anyways, send me ur email
I got problem, everytime I press Log In it shows just blank page and nothing on it. I did everything like tutorial says. Any help?
this guy is great
thanks for the great vids…
[...] here: PHP Tutorials: Register & Login: User login (Part 3) | PHP Blog Share and [...]
[...] reading here: PHP Tutorials: Register & Login: User login (Part 3) | PHP Blog Share and [...]
[...] PHP Tutorials: Register & Login: User login (Part 3) | PHP Blog [...]