Advertisement
Guest User

Untitled

a guest
Jun 12th, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. <?php session_start(); /* Starts the session */
  2. /* Check Login form submitted */if(isset($_POST['Submit'])){
  3. /* Define username and associated password array */$logins = array('admin' => 'password','username1' => 'password1','username2' => 'password2');
  4.  
  5. /* Check and assign submitted Username and Password to new variable */$Username = isset($_POST['Username']) ? $_POST['Username'] : '';
  6. $Password = isset($_POST['Password']) ? $_POST['Password'] : '';
  7.  
  8. /* Check Username and Password existence in defined array */if (isset($logins[$Username]) && $logins[$Username] == $Password){
  9.  
  10. /* Success: Set session variables and redirect to Protected page */$_SESSION['UserData']['Username']=$logins[$Username];
  11. header("location:index.php");
  12. } else {
  13. /*Unsuccessful attempt: Set error message */$msg="Username atau Password Salah";
  14. }
  15. }
  16. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement