Advertisement
Guest User

Untitled

a guest
May 20th, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.82 KB | None | 0 0
  1. <?php
  2. $passwords = array("name1"   =>"pass1",
  3.                    "name2"   =>"pass2");
  4.  
  5. if ($_POST['submit']) {
  6.    $username = $_POST['username'];
  7.    $password = $_POST['password'];
  8.                    
  9.    if ($password == $passwords[$username]) {
  10.        setcookie("username", $username, time()+1200);
  11.        echo $_POST['username'] . "<H2>Access granted.</H2>";
  12.  
  13.    }else{
  14.        setcookie("username", "", time()-3600);
  15.        echo "<H2>Invalid user name or password: access denied.</H2>";
  16.    }
  17. }
  18. ?>
  19.  
  20. <HTML>
  21. <BODY>
  22. <FORM METHOD="POST" ACTION="LoginFormAction.php">
  23. <H2>Login Page</H2>
  24. <BR><BR>
  25. User Name:
  26. <BR><INPUT TYPE="TEXT" NAME="username" SIZE="16">
  27. <BR><BR>
  28. Password:
  29. <BR><INPUT TYPE="PASSWORD" NAME="password" SIZE="16">
  30. <BR><BR> <BR><BR>
  31. <INPUT TYPE="SUBMIT" VALUE="Submit">
  32. </FORM>
  33. </BODY>
  34. </HTML>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement