Jump to content

Add X amount


wwedude

Recommended Posts

For example I have a table like:

 

Username Password Email Points

DudeEncrypted Passwordblah@yahoo.com28

 

Is their a code in PHP I could do, so when someone visits that page, it will add to points, x amount. So like when you visit a page, a specific user gets +3 to their points.

 

Sorry if I sound like a MySQL newbie, after all, I am.

 

Thanks!

Link to comment
Share on other sites

Maybe somthing like this?

 

 

<?php
$userid = $_SESSION['userid'];
$points = $_SESSION['points'];

if(isset($_SESSION['points']))
    $_SESSION['points'] = $_SESSION['points']+ 3;
else
    $_SESSION['points'] = 0;

$con = mysql_connect("localhost","username","pass");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }
  
  mysql_select_db("database", $conn);
  mysql_query("UPDATE `table` (points,userid) VALUES (\"$points\", \"$userid\") ON DUPLICATE KEY UPDATE points='$points'");

mysql_close($conn);
?>   

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.