Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. <?php
  2. echo "<div class='center1'>";
  3. $servername = "YOURHOST";
  4. $username= "YOURUSER";
  5. $password="YOURPASS";
  6. $db="YOURDBNAME";
  7. $conn = new MySQLI($servername,$username,$password,$db);
  8. if ($conn->connect_error){
  9. echo "error";
  10. }
  11. else{
  12. echo "<strong> Step 1: Connected to the DB Successfully</strong>";
  13.  
  14. //Collect User Information
  15. $time = date('Y-m-d H:i:s');
  16. $ip=$_SERVER['REMOTE_ADDR'];
  17. echo "<br />Your IP Address is: " . $ip . "<br /><br />";
  18.  
  19. //Record a visit
  20. $sql = "INSERT INTO IP_LOGGER (ip_address,date_time) VALUES ('$ip', '$time')";
  21. if(mysqli_query($conn, $sql)){
  22. echo "<strong>Step 2: Submission Successful</strong>";
  23. echo "<br />We've recorded your visit. Thanks for stopping by!";
  24. }
  25.  
  26. //Query the DB for number of times your IP is in it
  27. $sql = "SELECT * FROM IP_LOGGER WHERE ip_address LIKE'%$ip%'";
  28.  
  29.  
  30. if($search=mysqli_query($conn,$sql)){
  31. $numResults= mysqli_num_rows($search);
  32. echo "<strong><br /><br />Step 3: Query Database Successful </strong> <br />";
  33. echo "You've visited this site $numResults times <br /><br />";
  34. }
  35. }
  36. echo "</div>";
  37. ?>
  38.  
  39. <html>
  40. <style>
  41. .center1{margin-left:auto;margin-right:auto;width:295px;}
  42. </style>
  43. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement