Guest User

Untitled

a guest
Jun 25th, 2018
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.21 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.    
  4.     // Connecting to database //
  5.     include('sql_connect.php');
  6.    
  7.     $username = $obj_connection->real_escape_string($_POST['login_username']);
  8.     $password = $obj_connection->real_escape_string(md5($_POST['login_password']));
  9.    
  10.     if($username && $password) {
  11.         $sql_select = "SELECT username, password FROM ovi_users WHERE username = '$username'";
  12.        
  13.         $sql_result = $obj_connection->query($sql_select);
  14.        
  15.         $numrows = $sql_result->num_rows;
  16.        
  17.         // Return the row of user to check if it exist //
  18.         if($numrows != 0) {
  19.             while($row = $sql_result->fetch_assoc()) {
  20.                 $dbusername = $row['username'];
  21.                 $dbpassword = $row['password'];
  22.             }
  23.            
  24.             // Check if they both match //
  25.             if($username == $dbusername && $password == $dbpassword) {
  26.                 $_SESSION['username'] = $username;
  27.                 header('location: ../index.php?page=admin&show_home=true');
  28.             }
  29.             else {
  30.                 $_SESSION['login_pass'] = "Wrong password!";
  31.                 header('location: ../index.php');
  32.             }
  33.         }
  34.         else {
  35.             $_SESSION['login_user'] = "User doesnt ecxist!";
  36.             header('location: ../index.php');
  37.         }
  38.     }
  39.     else {
  40.         $_SESSION['login_blank'] = "All fields must be filled out!";
  41.         header('location: ../index.php');
  42.     }
  43.  
  44. ?>
Add Comment
Please, Sign In to add comment