Guest User

Untitled

a guest
Dec 10th, 2017
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require 'sqlconnect.php';
  4.  
  5. $user = $_POST['user'];
  6. $password = $_POST['password'];
  7.  
  8. $query = "SELECT * FROM users WHERE username='" . $user . "' AND password='" . $password . "'";
  9. $result = mysql_query($query);
  10. $number = mysql_num_rows($result);
  11. mysql_close();
  12. if ($number > 0)
  13. {
  14. $_SESSION['user'] = $user;
  15. header("location:main.php");
  16. }
  17. else
  18. {
  19. $line1 = $user . " tried to login at " . date('H') . ":" . date('i') . ":" . date('s') . " " . date('d') . "/" . date('m') . "/" . date('Y') . " IP: " . $_SERVER['REMOTE_ADDR'];
  20. $userinfo = $_SERVER['HTTP_USER_AGENT'] . "\n" . $line1 . "\n\n";
  21.  
  22. $myFile = "log.txt";
  23. $fh = fopen($myFile, 'a') or die("can't open file");
  24. fwrite($fh, $userinfo);
  25. fclose($fh);
  26. }
  27.  
  28. ?>
  29.  
  30. <html>
  31. <head>
  32. <title>Incorrent Login Details</title>
  33. <meta http-equiv="refresh" content="5;url=index.php"/>
  34. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
  35. <body bgcolor="#FFFFFF" text="#000000">
  36. <h1>Sorry - Incorrect login details were entered! Please Wait while you are redirected!</h1>
  37. </body>
  38. </html>
Add Comment
Please, Sign In to add comment