Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $cash = 20000000;
- $factories = Array(
- '1' => 12000000,
- '2' => 18000000,
- '3' => 24000000
- );
- if(strlen($_POST['submit']) > 0){
- $factoryCost = $factories[$_POST['factory']];
- if ($cash >= $factoryCost){
- $cash -= $factoryCost;
- echo "You have successfully built factory #" . $_POST['factory'] . '<br />';
- echo 'You have $' . number_format($cash) . ' remaining.<hr />';
- }else{
- echo 'You do not have sufficient funds. <span style="color: #900;">$' . number_format($cash - $factoryCost) . '</span><hr />';
- }
- }
- ?>
- <html>
- <head>
- <title>Factory Purchasing</title>
- </head>
- <body>
- <form method="POST">
- You Currently have $<?php echo number_format($cash); ?> in the bank.<br />
- Select Factory to purchase:<br />
- <?php
- foreach($factories as $num=>$cost){
- echo '<input type="radio" name="factory" value="' . $num . '" />#' . $num . ' ($' . number_format($cost) . ')<br />';
- }
- ?>
- <input type="submit" name="submit" value="Purchase" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement