Menu

#5 Energy Shop

open-accepted
nobody
None
1
2014-10-29
2003-10-26
Mark Hewitt
No

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).

Discussion

  • Matt Evans

    Matt Evans - 2003-10-29
    • priority: 5 --> 1
    • status: open --> open-accepted
     
  • Nobody/Anonymous

    Logged In: NO

    ok i click 1 then buy and nuffin happens :| why??

     
  • Mark Hewitt

    Mark Hewitt - 2006-01-28

    Working version.

     
  • Mark Hewitt

    Mark Hewitt - 2006-01-28

    Logged In: YES
    user_id=895320

    I fixed it finally. Just replace the &lt; with <, &gt; with
    >, and &quot; with ". Or, just download the "test.php" file
    I attached.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.