Advertisement
Guest User

Untitled

a guest
Jun 8th, 2017
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. function customError($errno, $errstr)
  2. {
  3. echo "<b>Error:</b> [$errno] $errstr<br />";
  4. echo "The error has been logged.";
  5. error_log(date (DATE_RSS)." Error: [$errno]
  6. $errstr".chr(13).chr(10),3, "btecinvalidlogin.txt");
  7. }
  8. //set error handler
  9. set_error_handler("customError",E_USER_WARNING);
  10. session_start();
  11. $_SESSION['login'] = "";
  12. if($user!="" && $pass!="")
  13. {
  14. $conn = @mysql_connect ("79.170.44.92", "cl41-cclarke", "cRt9G/3KH") or die ("Sorry - unable to
  15. connect to MySQL database.");
  16. $rs = @mysql_select_db ("cl41-cclarke", $conn) or die ("error");
  17. $sql = "SELECT * FROM dbUser WHERE username = '$user' AND
  18. password = '$pass'";
  19. $rs = mysql_query($sql,$conn);
  20. $result = mysql_num_rows($rs);
  21. if ($result > 0) $validated = true;
  22. if($validated)
  23. {
  24. $_SESSION['login'] = "OK";
  25. $_SESSION['username'] = $user;
  26. $_SESSION['password'] = $pass;
  27. $ip = $_SERVER["REMOTE_ADDR"];
  28. $date = date("d-m-Y H:i:s");
  29. $file = 'bteclogin.txt';
  30. // Open the file to get existing content
  31. $current = file_get_contents($file);
  32. // Append a new person to the file
  33. $current .= "$user logged in from IP Address of $ip on $date"."\r\n";
  34. // Write the contents back to the file
  35. file_put_contents($file, $current);
  36.  
  37. header('Location: protected02.php');
  38. }
  39. else
  40. {
  41. $_SESSION['login'] = "";
  42. trigger_error("Invalid username or password\n", E_USER_WARNING);
  43. }
  44. }
  45. else $_SESSION['login'] = "";
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement