Advertisement
Guest User

Untitled

a guest
May 30th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.40 KB | None | 0 0
  1. <?php // Starting Session
  2. $error=''; // Variable To Store Error Message
  3. if (isset($_POST['submit'])) {
  4. if (empty($_POST['username']) || empty($_POST['password'])) {
  5. $error = "Username or Password is invalid";
  6. }
  7. else
  8. {
  9. //echo $_POST['username'],$_POST['password']; Define $username and $password
  10. $username=$_POST['username'];
  11. $password=$_POST['password'];
  12. // Establishing Connection with Server by passing server_name, user_id and password as a parameter
  13. include_once('../inc/connection.php');
  14. // To protect MySQL injection for Security purpose
  15. $username = stripslashes($username);
  16. $password = stripslashes($password);
  17. //$username = mysqli_real_escape_string($username);
  18. //$password = mysqli_real_escape_string($password);
  19. // Selecting Database
  20. //$db = mysqli_select_db("woodsart", $connection);
  21. // SQL query to fetch information of registerd users and finds user match.
  22. $query = mysqli_query($connection,"select * from users where password='$password' AND username='$username'");
  23.  
  24. $rows = mysqli_num_rows($query);
  25. if ($rows == 1) {
  26. $userlevel=mysqli_fetch_array($query);
  27. session_start();
  28. $_SESSION['login_user']=$username;
  29. $_SESSION['login_level']=$userlevel['ulevel'];
  30. $_SESSION['user_branch']=$userlevel['showroom'];
  31. // Initializing Session
  32. header("location: /woodarts/index.php"); // Redirecting To Other Page
  33. } else {
  34. $error = "Username or Password is invalid";
  35. }
  36. mysqli_close($connection); // Closing Connection
  37. }
  38. }
  39. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement