Jump to content

Creating a PHP online site "store" help.


neex1233

Recommended Posts

Right now I'm trying to create a online store in PHP (no real money, just tokens). I have a few problems. First, I have no idea how to know if the user has enough tokens to buy the an object, and second I don't know how it would record what they buy to a MySQL database. Can I have any help? I wrote a small script with an idea of how I will do it:

 

<?php
ini_set ("display_errors", "1");
error_reporting(E_ALL);
require '/home/username/public_html/folder/config.php';
$username = mysql_real_escape_string($_SESSION['username']);
$price = mysql_real_escape_string($_POST["price"]);
$pro = mysql_real_escape_string($_POST["product"]);
$sql = "UPDATE users SET tokens=(tokens-$price)  WHERE username='$username'";
mysql_query($sql);
echo "Thank you for buying $pro!";
?> 

Link to comment
https://forums.phpfreaks.com/topic/163166-creating-a-php-online-site-store-help/
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.