Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Simative | Login</title>
- <link rel="shortcut icon" type="image/png" href="square.png">
- <link href="login.css" rel="stylesheet">
- </head>
- <body>
- <form action="home.php" method="post">
- <div class="container">
- <h4>Login</h4>
- <hr>
- <center><input type="text" placeholder="Username" name="Username" required></center>
- <center><input type="text" placeholder="Email" name="Email" required></center>
- <center><input type="text" placeholder="Password" name="Password" required></center>
- <center><input type="submit" name="submit"></center>
- <center><p>
- Have an account?
- <center><a href="register.php">Haven't got an account? Why not sign up!</a></p></center>
- </div>
- </form>
- </body>
- </html>
- <?php
- include("connect.php");
- session_start();
- // https://www.tutorialspoint.com/php/php_mysql_login.htm
- if($_SERVER["REQUEST_METHOD"] == "POST") {
- $myusername = mysqli_real_escape_string($db,$_POST['uname']);
- $mypassword = mysqli_real_escape_string($db,$_POST['pword']);
- $sql = "SELECT id FROM staff WHERE username = '$myusername' and password = '$mypassword'";
- $result = mysqli_query($db,$sql);
- $row = mysqli_fetch_array($result,MYSQLI_ASSOC);
- $active = $row['active'];
- $count = mysqli_num_rows($result);
- if($count == 1) {
- $_SESSION['login_user'] = $myusername;
- header("Location: home.php");
- die();
- }else {
- $error = "Your Login Name or Password is invalid";
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement