Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include_once("config.php");
- session_start();
- $message = "";
- if (isset($_POST['username'])) {
- $username = ($_POST['username']);
- $password =md5($_POST['password']);
- $password = ($password);
- $sql = "SELECT * FROM user WHERE username = '$username' && password='$password'";
- $query = mysqli_query($conn, $sql);
- $row = mysqli_fetch_row($query);
- $userid = $row[0];
- $checkuser = $row[5];
- $checkpassword = $row[4];
- $type = $row[1];
- $name = $row[2];
- $surname = $row[3];
- if ($username != $checkuser || $password != $checkpassword) {
- $message = " username or password entered is incorrect.";
- }
- if ($username == $checkuser && $password == $checkpassword) {
- $_SESSION['username'] = $username;
- $_SESSION['type'] =$type;
- $_SESSION['name'] = $name;
- $_SESSION['surname'] = $surname;
- $_SESSION['userid'] = $userid;
- if($_SESSION['type'] == "admin")
- {
- header("Location: adminindex.php");
- }
- else{
- header("Location: index.php");
- }
- }
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement