Advertisement
Guest User

Untitled

a guest
Oct 9th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. <?php
  2.  
  3. $servername = "localhost";
  4. $username = "root";
  5. $password = "sloboz13.";
  6. $dbname = "test";
  7.  
  8. $ip = $_SERVER['REMOTE_ADDR'];
  9.  
  10. // Create connection
  11. $conn = new mysqli($servername, $username, $password, $dbname);
  12. // Check connection
  13. if ($conn->connect_error) {
  14. die("Connection failed: " . $conn->connect_error);
  15. }
  16.  
  17. $sql = 'SELECT * FROM test.ips where ip="127.0.0.1";';
  18.  
  19. $result = $conn->query($sql);
  20.  
  21. $count = 1;
  22. if ($result->num_rows > 0) {
  23. $row = $result->fetch_assoc();
  24. $count = intval($row["count"]);
  25. $count++;
  26. $sql = "UPDATE test.ips SET count=$count WHERE ip='$ip'";
  27. } else {
  28. $sql = "INSERT INTO test.ips (ip, count) VALUES ('$ip', 1)";
  29. }
  30.  
  31. if ($conn->query($sql) === TRUE) {
  32. /* success */
  33. } else {
  34. /* error $conn->error */
  35. }
  36. if ($count > 10) {
  37. echo 'window.location.href="http://www.google.com"';
  38. }
  39.  
  40. $conn->close();
  41.  
  42.  
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement