Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //DB-varaibles
- $host = "dbirkemalm.com.mysql";
- $username = "dbirkemalm_com";
- $password ="8ejxQ4Pn";
- $db_name = "dbirkemalm_com";
- $ip_table = 'ips';
- $vote_table = 'votes';
- //Variables
- $ip = $_SERVER['REMOTE_ADDR'];
- $vote = $_GET['id'];
- //Connect to DB
- mysql_connect("$host", "$username", "$password") or die ("cannot connect");
- mysql_select_db("$db_name") or die ("cannot select DB");
- //Check if IP exists in DB.
- $checkip = "SELECT * FROM $ip_table WHERE ip = '$ip'";
- $checkipr = mysql_query($checkip);
- $iprows = mysql_num_rows($checkipr);
- //If IP does not exist, insert it.
- if($iprows == 0){
- $ipinsert = "INSERT INTO $ip_table VALUES($ip)";
- $ipinsquery = mysql_query($ipinsert);
- //When IP is inserted, do vote.
- $votequery = "INSERT INTO $vote_table VALUES($vote)";
- $dovote = mysql_query($votequery);
- }
- else{
- echo "Nothing";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement