Advertisement
Guest User

index.php

a guest
Sep 7th, 2017
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.81 KB | None | 0 0
  1. <?php
  2. session_start();
  3. if(isset($_SESSION['username']) || !empty($_SESSION['username'])){
  4.     header("location:blog.php");
  5. }
  6. ?>
  7. <!DOCTYPE html>
  8. <html>
  9.     <head>
  10.         <meta charset="utf-8">
  11.             <title>Template Login</title>
  12.         <link rel="stylesheet" href="style.css">
  13.         <meta name="viewport" content="width=device-width , initial-scale=1">
  14.     </head>
  15.     <body>
  16.  
  17.         <div id="login">
  18.             <div class="center">
  19.                 <h2>Login - Web</h2>
  20.  
  21.                    
  22.                     <?php
  23.                         if (isset($_POST['login'])) {
  24.                             $username = $_POST['username'];
  25.                             $filter = mysql_real_escape_string(stripcslashes(strip_tags(htmlspecialchars($username, ENT_QUOTES))));
  26.                             $password = md5($_POST['password']);
  27.                             //inisialisasi memakai akun tanpa database
  28.                             $user = 'dganisha';
  29.                             $key = md5('11rpl1');
  30.  
  31.                             if ((!empty($username) && !empty($password))) {
  32.                                 if($username == $user && $password == $key){
  33.                                     $_SESSION['username'] = $username;
  34.                                     $_SESSION['password'] = $password;
  35.                                     //dialihkan ke halaman utama
  36.                                     header("location:blog.php");
  37.                                 }else{
  38.                                     echo "<p style='color:red;font-size:13px;margin:2px auto;'>(*) Usernanme atau Password Salah. </p>";
  39.                                 }
  40.                             }else{
  41.                                     echo "<p style='color:red:font-size:13px;margin:2px auto;'>(*) Silahkan isi Form yang telah tersedia </p>";
  42.                                 }
  43.                             }
  44.                        
  45.                         ?>
  46.                     <form class="f1" action="" method="post">
  47.                         <input class="itpw" type="text" name="username" placeholder="Username or Email" required><br>
  48.                         <input class="itpw" type="password" name="password" placeholder="Password" required><br>
  49.                         <input class="its" type="submit" name="login" value="LOGIN">
  50.  
  51.                     </form>
  52.                     <p><a href="#">Forget Your Password? </a> | <a href="#">Created an account</a> </p>
  53.             </div>
  54.         </div>
  55.     </body>
  56. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement