I'm a bit new to php/mysql, I made a login/register page, and when I'm logged in (I'm creating a simple game in php) I want to do the following:
Beside my username/password in my database I have a column for example 'gold'
as int
. What I want to do is, create a simple <a href='gold.php'>LINK</a>
in HTML, which links me to the php code, adds 1 gold to my 'gold'
column, and header(location: index.php)
returns.
Since you keep your queries in an old school fashion, do it like this:
//gold.php
session_start();
mysqli_query("UPDATE users SET gold = gold + 1 WHERE UserId = $_SESSION['username']");
Better use bound parameters though.