Forgive me, I REALLY suck at code. I'm more of a design person.
And I'm sure the answer is out there on the internet but I can't find it because I'm not sure what to search for, I've tried.
After someone logs in I want it to say "welcome" and their first_name. I have it doing this after they register and it logs them in, but thats because it specifically gets their first name from the form when they register. But logging in its only asking for their email address and password on the form, but i'd like it to then retrieve the first_name that corresponds from the database and put it on the members page. I know its a matter of writing a function, but like I said I suck at that.
Here's what happens on the login page:
// if $submit variable set, login info submitted:
if(isset($_POST["Submit"])) {
// Check fields were filled in
field_validator("Email Address", $_POST["email"], "email");
field_validator("Password", $_POST["password"], "string", 6, 16);
// if there are $messages, errors were found in validating form data
if($messages){
doIndex();
exit;
}
// now check the email/pass pair match those stored in the db:
if( !($row = checkPass($_POST["email"], $_POST["password"])) ) {
// email/passwd string not correct, create an error message:
$messages[]="Incorrect email/password, please try again";
}
/*
If there are error $messages, errors were found in validating form data above.
Call the 'doIndex()' function (which displays the login form) and exit.
*/
if($messages){
doIndex();
exit;
}
/*
If we got to this point, there were no errors - start a session using the info
returned from the db:
*/
cleanMemberSession($row["email"], $row["password"]);
// and finally forward user to members page
header("Location: members.php");
} else {
// The login form wasn't filled out yet, display the login form for the user to fill in:
doIndex();
}
And where should it go, before or after the initialization of the session?