Advertisement
Guest User

Untitled

a guest
Jul 29th, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.87 KB | None | 0 0
  1. <?php
  2.  
  3. //DB-varaibles
  4. $host = "dbirkemalm.com.mysql";
  5. $username = "dbirkemalm_com";
  6. $password ="8ejxQ4Pn";
  7. $db_name = "dbirkemalm_com";
  8. $ip_table = 'ips';
  9. $vote_table = 'votes';
  10.  
  11. //Variables
  12. $ip = $_SERVER['REMOTE_ADDR'];
  13. $vote = $_GET['id'];
  14.  
  15. //Connect to DB
  16. mysql_connect("$host", "$username", "$password") or die ("cannot connect");
  17. mysql_select_db("$db_name") or die ("cannot select DB");
  18.  
  19. //Check if IP exists in DB.
  20. $checkip = "SELECT * FROM $ip_table WHERE ip = '$ip'";
  21. $checkipr = mysql_query($checkip);
  22. $iprows = mysql_num_rows($checkipr);
  23.  
  24.  
  25. //If IP does not exist, insert it.
  26. if($iprows == 0){
  27.     $ipinsert = "INSERT INTO $ip_table VALUES($ip)";
  28.     $ipinsquery = mysql_query($ipinsert);
  29.     //When IP is inserted, do vote.
  30.     $votequery = "INSERT INTO $vote_table VALUES($vote)";
  31.     $dovote = mysql_query($votequery);
  32. }
  33.  
  34. else{
  35.     echo "Nothing";
  36. }
  37.  
  38.  
  39.  
  40.  
  41. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement