Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Jun 2010
    Posts
    163
    Thanks
    10
    Thanked 0 Times in 0 Posts

    Get Info When Link Is Clicked

    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 Code:
    <?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>

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    $viewedsites = "UPDATE userstats SET exp='$newexp', level='$newlevel', todaysurfed='$siteview' WHERE id='$userid'";
    mysql_query($viewedsites);
    Change the above to
    PHP Code:
    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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Jun 2010
    Posts
    163
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Hi, sorry for the late response.

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

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,851
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    What do you get for the output of that echo?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Jun 2010
    Posts
    163
    Thanks
    10
    Thanked 0 Times in 0 Posts
    This is echoed:

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

  • #6
    Senior Coder
    Join Date
    Jun 2008
    Location
    New Jersey
    Posts
    2,535
    Thanks
    45
    Thanked 259 Times in 256 Posts
    From your first code it means that your session is not working properly, or the userid is not being stored properly.

  • #7
    Regular Coder
    Join Date
    Jun 2010
    Posts
    163
    Thanks
    10
    Thanked 0 Times in 0 Posts
    Alright. Thanks. I guess I'll have to keep working at it.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •