I am attempting to write a script that will add 100 points to a user's account once they click on a link. I'm using some javascript that has the link, and some php that will $_GET the URL information that was passed in, then update the user's points.
Here's the code I've got, but I've yet to get it to work successfully.
<?php
session_start();
include('inc/connect.php');
$userid = $_SESSION['userid'];
$viewedquery = mysql_query("SELECT `todaysurfed`, `exp`, `level` FROM `userstats` WHERE id='$userid'");
$row = mysql_fetch_assoc($viewedquery);
$todaysurfed = $row['todaysurfed'];
if (isset($_GET['next'])){
include('exp.php');
$siteview ++ ;
$viewedsites = "UPDATE userstats SET exp='$newexp', level='$newlevel', todaysurfed='$siteview' WHERE id='$userid'";
mysql_query($viewedsites);
}
<html>
<head>
<title>My Site</title>
<script>
top.surfbar.location = 'surfbar.php'
top.Site.location = '<?php echo $url; ?>';
</script>
<link rel="stylesheet" type="text/css" href="styles/surfbar.css" />
<script type="text/javascript">
var time = 2;
function startCountdown(){
var t = setTimeout("countdown()", 1000);
}
function countdown(){
--time;
if(time == 0){
document.getElementById("countdown").innerHTML = '<a href="surfbar.php?next=<?php echo urlencode($siteview);?>">Next</a>';
}else{
document.getElementById("countdown").innerHTML = time;
var t = setTimeout("countdown()", 1000);
}
}
</script>
</head>
<body onload="startCountdown();">
<table width="100%" height="100%" cellspacing="0" cellpadding="0" border="0">
<?php
echo "<tr><td style=\"background:#333333;height:80px;border-bottom:#aaaaaa solid 2px;\">";
include('surfbar.php');
echo "</td></tr>";
?>
<tr><td>
<iframe src="<?php echo $url;?>" width="100%" height="100%" frameborder="0" name="Site" marginwidth="O" marginheight="0" noresize scrolling="auto">
<p>Your browser does not support iframes.</p>
</iframe>
</td></tr>
</table>
</body>
</html>