Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- require('db.php');
- session_start();
- // If form submitted, insert values into the database.
- if (isset($_POST['username'])){
- $username = stripslashes($_REQUEST['username']); // removes backslashes
- $username = mysqli_real_escape_string($con,$username); //escapes special characters in a string
- $password = stripslashes($_REQUEST['password']);
- $password = mysqli_real_escape_string($con,$password);
- //Checking is user existing in the database or not
- $query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
- $result = mysqli_query($con,$query) or die(mysql_error());
- $rows = mysqli_num_rows($result);
- if($rows==1)
- {
- if($rows ['level'] == "student")
- {
- header("localtion: student.php");
- }
- elseif($rows ['level'] == "manager")
- {
- header("location: manager.php");
- }
- }
- else
- {
- echo "wrong Username or Password";
- }
- ?>
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>Login</title>
- <link rel="stylesheet" href="css2/style.css" />
- </head>
- <body>
- <div class="form">
- <h1>Log In</h1>
- <form action="" method="post" name="login">
- <input type="text" name="username" placeholder="Username" required />
- <input type="password" name="password" placeholder="Password" required />
- <input name="submit" type="submit" value="Login" />
- </form>
- <p>Not registered yet? <a href='registration.php'>Register Here</a></p>
- </div>
- <?php } ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement