This question already has an answer here:
- Use array in PHP to compare username/password 1 answer
- PHP Login with Username/Password 2 answers
- Making username and userid into an array 5 answers
- Easy login script without database 10 answers
- Best way to store password in database [closed] 8 answers
How do I edit login.php below to add some usernames and passwords? For example, username1 with password1, username2 with password2, etc. Please help me. thanks
<?php
$error = "";
if(isset($_POST['username'],$_POST['password'])){
/*** You can change username & password ***/
$user = array(
"user" => "username1",
"pass"=> "password1"
);
$username = $_POST['username'];
$pass = $_POST['password'];
if ($username == $user['user'] && $pass == $user['pass']) {
session_start();
$_SESSION['simple_login'] = $username;
header("Location: index.php");
exit();
} else {
$error = '<div class="alert alert-danger alert-dismissible fade in" role="alert">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>Invalid Username or Password !
</div>';
}
}
?>
</div>