Advertisement
Guest User

login

a guest
Sep 16th, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.20 KB | None | 0 0
  1. <?php
  2.     session_start();
  3. ?>
  4. <!DOCTYPE HTML>
  5. <head>
  6.     <meta http-equiv="content-type" content="text/html" charset="utf-8"  />
  7.     <title>Đăng nhập hệ thống</title>
  8.     <style>
  9.         body{
  10.             width:500px;
  11.             margin: 100px auto;
  12.         }
  13.         h1{
  14.             color:blue;
  15.             font-size:14px;
  16.             text-transform: uppercase;
  17.             padding-left: 80px;
  18.         }
  19.         label{
  20.             float:left;
  21.             width:80px;
  22.         }
  23.         p{
  24.             padding-left: 85px;
  25.             color: red;
  26.         }
  27.         input{
  28.             margin-bottom: 5px;
  29.         }
  30.     </style>
  31. </head>
  32. <body>
  33.     <h1>Đăng nhập hệ thống</h1>
  34.     <?php
  35.             $username = $password = "";
  36.             if(isset($_POST['ok'])){
  37.                 if(!isset($_POST['username']) || $_POST['username'] == NULL){
  38.                     echo "<p>Vui lòng nhập họ tên đầy đủ<p>";
  39.                 }else{
  40.                     $username = $_POST['username'];
  41.                 }
  42.                 if(!isset($_POST['password']) || $_POST['password'] == NULL){
  43.                     echo "<p>Mật khẩu không được bỏ trống<p>";
  44.                 }else{
  45.                     $password = $_POST['password'];
  46.                 }
  47.                 if($username =='admin' && $password =='123456'){                  
  48.                     $_SESSION['user'] = $username;
  49.                     $_SESSION['password'] = $password;
  50.                     echo "<p>UserName và password đã khớp đúng !!!</p>";                    
  51.                     echo "<div>";      
  52.                         echo "<a href=''>Chào bạn: " .$_SESSION['user']."</a>&nbsp;&nbsp;&nbsp;&nbsp;";
  53.                         echo "<a href='logout.php'>Đăng xuất</a>";
  54.                     echo "</div>";                   
  55.                     }else{
  56.                         echo "<p>UserName hoặc password không đúng !!!</p>";  
  57.                     }
  58.                 }
  59. ?>
  60.     <form action="login.php" method="post">
  61.         <label>UserName</label><input type="text" name="username" size="25" value="" /><br />
  62.         <label>Password</label><input type="text" name="password" size="25" value="" /><br />
  63.         <label>&nbsp;</label>
  64.         <input type="submit" name="ok" value="Đăng nhập" />
  65.     </form>
  66. </body>
  67. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement