subhomoy Posted April 27, 2013 Share Posted April 27, 2013 Hello every one i've created this code which will track the unique visits per 24 hr with the help of date and ip.... The code is shown below... <?php require_once '../dbconfig.php'; echo $date = date("Y-m-d"); $uid = $_SESSION['id']; $ip = $_SERVER['HTTP_HOST']; $adi = $_REQUEST['aid']; $a = mysql_query("SELECT * FROM ad_clk WHERE id='$adi'") or die(mysql_error()); while($te = mysql_fetch_array($a)){ $imp = $te['impression']; echo $money = $te['money']; $link = $te['link']; } ?> <form method="post" action=""> <input type="submit" name="submit" value="Credit" /> </form> <?php if(isset($_REQUEST['submit'])){ $r = @mysql_query("SELECT * FROM ad_clk_hits WHERE adv_id='$adi'") or die(mysql_error()); while($re = mysql_fetch_array($r)){ $date1 = $re['date']; $ip1 = $re['ip']; $adv = $re['adv_id']; } if(($ip==$ip1) && ($date==$date1) && ($adi==$adv)){ echo 'You have already visited this advertisement today'; } else{ echo "Thank You"; $imp = $imp-1; $e = mysql_query("UPDATE ad_clk SET impression='$imp' WHERE id='$adi'") or die(mysql_error()); $w = mysql_query("INSERT IGNORE INTO ad_clk_hits(id,user_id,adv_id,date,ip) VALUES('','$uid','$adi','$date','$ip')") or die(mysql_error()); } } clearstatcache(); ?> <iframe src="<?php echo $link; ?>" width="100%" height="100%"></iframe> Its working fine but there is one problem... I have tested with changing the date of my computer and its counting unique but sometimes when i'm refreshing the page continuosly by pressing F5 for testing purpose, some times the duplicate values with same date and ip are dumped into database... and again after some more refreshes it works fine... Why the script is behaving abnormally???? Any help will be greatly appreciated... Thank u in advance... Quote Link to comment Share on other sites More sharing options...
subhomoy Posted April 27, 2013 Author Share Posted April 27, 2013 Anybody plz help...... Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.