Advertisement
Guest User

Untitled

a guest
Apr 24th, 2018
196
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.19 KB | None | 0 0
  1. <?php
  2.    include("config.php");
  3.    session_start();
  4.    
  5.    if($_SERVER["REQUEST_METHOD"] == "POST") {
  6.       // username and password sent from form
  7.      
  8.       $myusername = mysqli_real_escape_string($db,$_POST['username']);
  9.       $mypassword = mysqli_real_escape_string($db,$_POST['password']);
  10.      
  11.       $sql = "SELECT id FROM admin WHERE username = '$myusername' and passcode = '$mypassword'";
  12.       $result = mysqli_query($db,$sql);
  13.  
  14.       $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  15.       $active = $row['active'];
  16.      
  17.       $count = mysqli_num_rows($result);
  18.  
  19.       // If result matched $myusername and $mypassword, table row must be in 1 row
  20.        
  21.       if($count == 1) {
  22.          session_register("myusername");
  23.          $_SESSION['login_user'] = $myusername;
  24.          
  25.         header("location:welcome.php");
  26.       }else {
  27.          $error = "Your Login Name or Password is invalid";
  28.       }
  29.    }
  30. ?>
  31. <html>
  32.    <head>
  33.       <title>Login Page</title>
  34.      
  35.       <style type = "text/css">
  36.          body {
  37.             font-family:Arial, Helvetica, sans-serif;
  38.             font-size:14px;
  39.          }
  40.          label {
  41.             font-weight:bold;
  42.             width:100px;
  43.             font-size:14px;
  44.          }
  45.          .box {
  46.             border:#666666 solid 1px;
  47.          }
  48.       </style>
  49.    </head>
  50.    
  51.    <body bgcolor = "#FFFFFF">
  52.       <div align = "center">
  53.          <div style = "width:300px; border: solid 1px #333333; " align = "left">
  54.             <div style = "background-color:#333333; color:#FFFFFF; padding:3px;"><b>Login</b></div>
  55.             <div style = "margin:30px">
  56.                
  57.                <form action = "" method = "POST">
  58.                   <label>UserName  :</label><input type = "text" name = "username" class = "box"/><br /><br />
  59.                   <label>Password  :</label><input type = "password" name = "password" class = "box" /><br/><br />
  60.                   <input type = "submit" value = " Submit "/><br />
  61.                </form>
  62.                
  63.                <div style = "font-size:11px; color:#cc0000; margin-top:10px"><?php echo $error;?></div>
  64.             </div>
  65.          </div>
  66.       </div>
  67.    </body>
  68. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement