Guest User

Untitled

a guest
Mar 9th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. <?
  2.     session_start();
  3.     include '../connect.php';
  4. ?>
  5. <!DOCTYPE html>
  6. <html>
  7.     <head>
  8.         <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  9.         <title></title>
  10.     </head>
  11.     <body>
  12.        
  13.        <?php
  14.                 if ($_SESSION['id'] == false) {
  15.        ?>
  16.        
  17.             <h2> Login Admin </h2>
  18.             <form action="index.php" method="post">
  19.            
  20.             <label> username </label> <input type="text" name="username"/>
  21.             <label> passowrd </label> <input type="text" name="password"/>
  22.                         <input type="submit" value="login"/>
  23.             </form>
  24.            
  25.             <?php
  26.                
  27.                
  28.                
  29.                 if(isset ($_POST['username']) or isset ($_POST['password']))
  30.                 {
  31.                     if($_POST['username'] == "" or $_POST['password'] == "") {
  32.                                                 echo "username dan password belum di masukan !";
  33.                                         } else
  34.                                         {
  35.                                             $query = mysql_query("select * from admin where username = '$_POST[username]' and password = '$_POST[password]'");
  36.                                             $num = mysql_num_rows($query);
  37.                                                     if($num == 0){
  38.                                                         echo "Username tidak di temukan !";
  39.                                                     } else
  40.                                                     {
  41.                                                         $data = mysql_fetch_array($query);
  42.                                                         $_SESSION['id'] = $data['id'];
  43.                                                         echo "<meta http-equiv='refresh' content='0;url=index.php' />";
  44.                                                     }
  45.                                         }
  46.            
  47.                                 }
  48.                         } else {
  49.             ?>
  50.                         <h3>Welcome Admin</h3>
  51.             <p>Ini adalah halaman admin untuk mengelola toko anda</p>
  52.                         <a href="add_product.php"> Add Product </a>
  53.                         <a href="logout.php"> Logout </a>
  54.                          <?php
  55.                          }
  56.                         ?>
  57.        
  58.     </body>
  59. </html>
Add Comment
Please, Sign In to add comment