Advertisement
Guest User

Untitled

a guest
Jun 13th, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1.  
  2. <?php
  3. session_start();
  4.  
  5. if (isset($_POST['username'])) {
  6.  
  7. // Include the databas connection script
  8. include_once("dbconnect.php");
  9.  
  10. // Set the posted data from the form into local variables
  11. $usname = strip_tags($_POST['username']);
  12. $paswd = strip_tags($_POST['password']);
  13.  
  14. $usname = mysqli_real_escape_string($dbCon, $usname);
  15. $paswd = mysqli_real_escape_string($dbCon, $paswd);
  16.  
  17. $paswd = md5($paswd); // using md5 just for testing purposes
  18.  
  19. $sql = "SELECT username, password FROM users WHERE username = '".$usname."' AND activated = '1' LIMIT 1";
  20. $query = mysqli_query($dbCon, $sql);
  21. $row = mysqli_fetch_row($query);
  22. $uid = $row[0];
  23. $dbUsname = $row[1];
  24. $dbPassword = $row[2];
  25.  
  26. // Check if the username and the password they entered was correct
  27. if ($usname == $dbUsname && $paswd == $dbPassword) {
  28. // Set session
  29. $_SESSION['username'] = $usname;
  30. $_SESSION['password'] = $uid;
  31. // Now direct to users feed
  32. header("Location: site.php");
  33. } else {
  34. echo "<h2><center>הפרטים שהזנת הנם שגויים, אנא נסה שנית.
  35. <br />
  36. </center></h2>";
  37. }
  38.  
  39. }
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement