Page 1 of 1

Online PHP Shop Help

Posted: Sun Jun 21, 2009 7:54 pm
by neex1233
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:

Code: Select all

 
<?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!";
?> 
 
:banghead: :banghead: :banghead: :cry: :cry: :cry:

Re: Online PHP Shop Help

Posted: Mon Jun 22, 2009 12:11 am
by mischievous
Hey i am writing up the script for you and will post it tomorrow morning... i am too tired tonight to finish it out... :roll: