This doesn't really need anything special, seeing as how
the MySQL files are already there, so you'll just need to
download the file I attached on this post. Or, you can
just copy this code into a new file named "eshop.php":
<?php $title = "Energy Shop"; include("header.php"); ?>
<?php
$prices = mysql_query("select * from market");
$pa = mysql_fetch_array($prices);
$ener_price = 10;
if ($action != buy) {
print "Energy pills are a rare commodity... right
now its $ener_price platinum a pill. How much you
want?";
print "<form method=post action=eshop.php?
action=buy>";
print "I want <input type=text name=ener>
energy pills. <input type=submit value=Buy>";
print "</form>";
} else {
$plat = str_replace("--","", $ener);
$cost = ($ener * $ener_price);
if ($cost > $stat[platinum] || $plat <= 0) {
print "You cant afford that! (<a
href=eshop.php>back</a>)";
} else {
mysql_query("update players set
platinum=platinum-$cost where id=$stat[id]");
mysql_query("update players set
energy=energy+$ener where id=$stat[id]");
print "You got <b>$ener</b> energy
pills for <b>$cost</b> platinum.";
}
}
?>
<?php include("footer.php"); ?>
It's not too much, but it does work fine for me. If
anyone runs into problems, well, I'm not too sure how to
solve them, I just made the script, run at your own risk
(which isn't too big if you ask me).
Logged In: NO
ok i click 1 then buy and nuffin happens :| why??
Working version.
Logged In: YES
user_id=895320
I fixed it finally. Just replace the < with <, > with
>, and " with ". Or, just download the "test.php" file
I attached.