Advertisement
Guest User

Untitled

a guest
Aug 19th, 2018
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.72 KB | None | 0 0
  1. <html>
  2.     <head>
  3.         <title>Simative | Login</title>
  4.         <link rel="shortcut icon" type="image/png" href="square.png">
  5.         <link href="login.css" rel="stylesheet">
  6.  
  7.  
  8.     </head>
  9.     <body>
  10.      
  11.        
  12.  
  13.      
  14.      
  15.  
  16.         <form action="home.php" method="post">  
  17.         <div class="container">
  18.             <h4>Login</h4>
  19.             <hr>
  20.             <center><input type="text" placeholder="Username" name="uname" required></center>
  21.             <center><input type="text" placeholder="Email" name="email" required></center>
  22.             <center><input type="text" placeholder="Password" name="pword" required></center>
  23.             <center><input type="submit" name="Submit"></center>
  24.             <center><p>
  25.             Have an account?
  26.             <center><a href="register.php">Haven't got an account? Why not sign up!</a></p></center>
  27.  
  28.  
  29.         </div>
  30.       </form>
  31. </body>
  32. </html>
  33.  
  34.  
  35.  
  36. <?php
  37.  
  38.     include("connect.php");
  39.     session_start();
  40.     // https://www.tutorialspoint.com/php/php_mysql_login.htm
  41.      if($_SERVER["REQUEST_METHOD"] == "POST") {
  42.  
  43.       $myusername = mysqli_real_escape_string($db,$_POST['uname']);
  44.       $mypassword = mysqli_real_escape_string($db,$_POST['pword']);
  45.  
  46.       $sql = "SELECT id FROM staff WHERE username = '$myusername' and password = '$mypassword'";
  47.       $result = mysqli_query($db,$sql);
  48.       $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
  49.       $active = $row['active'];
  50.  
  51.       $count = mysqli_num_rows($result);
  52.  
  53.       if($count == 1) {
  54.          $_SESSION['login_user'] = $myusername;
  55.          header("Location: home.php");
  56.          die();
  57.       }else {
  58.          $error = "Your Login Name or Password is invalid";
  59.       }
  60.    }
  61. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement