...

View Full Version : Get Info When Link Is Clicked



Smudly
06-19-2010, 12:17 AM
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>

abduraooft
06-19-2010, 08:16 AM
$viewedsites = "UPDATE userstats SET exp='$newexp', level='$newlevel', todaysurfed='$siteview' WHERE id='$userid'";
mysql_query($viewedsites); Change the above to

echo $viewedsites = "UPDATE userstats SET exp='$newexp', level='$newlevel', todaysurfed='$siteview' WHERE id='$userid'";
mysql_query($viewedsites) or die(mysql_error()); and see if the execution really reaches there and there's no error in your query.

Smudly
06-22-2010, 06:03 AM
Hi, sorry for the late response.

I typed in that code and got no errors. It's still having the same problems.

abduraooft
06-22-2010, 07:28 AM
What do you get for the output of that echo?

Smudly
06-23-2010, 05:32 PM
This is echoed:

UPDATE userstats SET exp='', level='', todaysurfed='1' WHERE id=''

Keleth
06-23-2010, 05:38 PM
From your first code it means that your session is not working properly, or the userid is not being stored properly.

Smudly
06-23-2010, 05:40 PM
Alright. Thanks. I guess I'll have to keep working at it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum