Complete, simple, working example of a login screen-system using php functions cookies and a mysql database for begginers. "; }else{ header("Location: $SCRIPT_NAME"); //If the password didn't match, redirect to this page in which $username and $password are reset therefore the first if () never gets executed } } if($msg) echo $msg; //if $msg is set echo it, resulting in a redirect to the next page. ?> // This is the login screen Login
// submit form data to this page
Welcome!



Username:
Password:
/* That was the login page Next is some code you can put into a different file (named 'login_check.inc' or something) that you include() on each page you want protected on your site. It uses the cookie from the first script to verify user has already been there. */