Advertisement
Guest User

Untitled

a guest
Aug 17th, 2016
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.12 KB | None | 0 0
  1. /*plantilla de la pagina*/
  2.  
  3. <?php
  4.  
  5. $con_error='Could not connect';
  6.  
  7. $mysql_host='localhost';
  8. $mysql_user='root';
  9. $mysql_pass='';
  10. $mysql_db='new_database';
  11.  
  12. /*
  13.  
  14. /*connect to server / database*/
  15. $mysqlcon=mysqli_connect($mysql_host, $mysql_user, $mysql_pass) or die($con_error);
  16.  
  17. /*select database*/
  18. mysqli_select_db($mysqlcon, $mysql_db) or die($con_error);
  19.  
  20. ?>
  21.  
  22.  
  23.  
  24. /*codigo que aumenta el contador por ip y guarda la ip*/
  25.  
  26. <?php
  27. $user_ip=$_SERVER['REMOTE_ADDR'];
  28. mysqli_query($mysqlcon, "INSERT INTO hit_ip VALUES ($user_ip)");
  29.  
  30.  
  31. function add_ip () {
  32. global $mysqlcon;
  33. global $user_ip;
  34.  
  35. $query="SELECT ip FROM hit_ip WHERE ip='$user_ip'";
  36. $query_run=mysqli_query($mysqlcon, $query);
  37. if (mysqli_num_rows($query_run)==NULL) {
  38. $ip_query="INSERT INTO hit_ip VALUES ($user_ip)";
  39. $result_ip=mysqli_query($mysqlcon, $ip_query);
  40. if ($result_ip) {
  41. $query_count="UPDATE hit_counter SET value=value+1 WHERE hits='hits'";
  42. $result_query=mysqli_query($mysqlcon, $query_count);
  43. }
  44. }
  45. }
  46.  
  47.  
  48. add_ip();
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement