hi everyone, how to create a simple user login without database? i want to write in a php page (validation.php) the usernames and passwords, to create a cookie for each user and each page to has a validation script. can anybody give some help? thanks in advance.
Would've thought something like this should be sufficient: if( $_POST["user"] == "user1" && $_POST["pass"] == "pass" ) { // User #1: Info is correct, do whatever... $_SESSION["user"] = $_POST["user"]; echo "Logged in as: ". $_SESSION["user"]; } elseif( $_POST["user"] == "user2" && $_POST["pass"] == "pass" ) { // User #2: Info is correct, do whatever... $_SESSION["user"] = $_POST["user"]; echo "Logged in as: ". $_SESSION["user"]; } else { // User enter wrong info, do whatever... echo "No."; } PHP: This is presuming you're using a form which uses POST as the method. Then on pages where you want to see if they are logged in or not: if( !isset( $_SESSION["user"] ) { // User isn't logged in. Probably re-direct them to the login form... echo "Not logged in."; die( ); } else { // User is logged in, do whatever... echo "Welcome to the secret members only area!"; } PHP: