Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- /* PASSWORD MD5 */
- $data = array(
- array(
- 'u' => 'admin',
- 'p' => '21232f297a57a5a743894a0e4a801fc3'
- )
- );
- if($_SERVER['REQUEST_METHOD'] == 'POST' && isset($_POST['__login'])){
- $username = isset($_POST['username']) ? $_POST['username'] : null;
- $password = isset($_POST['password']) ? $_POST['password'] : null;
- $login = array(
- 'u' => $username,
- 'p' => md5($password)
- );
- if(in_array($login, $data)){
- $_SESSION['__valid'] = TRUE;
- header('Location: '.$_SERVER['PHP_SELF']);
- }
- else{
- echo "<script>alert('Wrong!')</script>";
- }
- }
- ?>
- <?php if(!isset($_SESSION['__valid'])){ ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge">
- <title>Login Page</title>
- <style type="text/css" media="screen">
- .mx-auto{
- margin-left: auto;
- margin-right: auto;
- display: block;
- }
- </style>
- </head>
- <body>
- <form action="<?= $_SERVER['PHP_SELF'] ?>" method="post" accept-charset="utf-8">
- <input type="text" name="username" class="mx-auto" class="username" placeholder="Username"><br>
- <input type="password" name="password" class="mx-auto" placeholder="Password"><br>
- <button type="submit" name="__login" value="Checking Login" class="mx-auto">Login</button>
- </form>
- </body>
- </html>
- <?php exit();} ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement