Jump to content

Add X amount


wwedude

Recommended Posts

For example I have a table like:

 

Username Password Email Points

DudeEncrypted [email protected]

 

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
https://forums.phpfreaks.com/topic/116533-add-x-amount/
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
https://forums.phpfreaks.com/topic/116533-add-x-amount/#findComment-599336
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.