Online PHP Shop Help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
neex1233
Forum Newbie
Posts: 10
Joined: Sun Jun 21, 2009 7:44 pm

Online PHP Shop Help

Post 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:
mischievous
Forum Commoner
Posts: 71
Joined: Sun Apr 19, 2009 8:59 pm

Re: Online PHP Shop Help

Post 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:
Post Reply