Advertisement
DragonOsman

display_price.php

Dec 18th, 2016
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. quote.php:
  2. <?php
  3.  
  4.     require("../includes/config.php");
  5.    
  6.     render("submit_symbol.php", ["title" => "Submit Symbol"]);
  7.  
  8. ?>
  9.  
  10. submit_symbol.php:
  11. <form action="get_price.php" method="post">
  12.     <fieldset>
  13.         <legend>Symbol Information</legend>
  14.         <input type="text" name="symbol" placeholder="Enter Symbol Here" value=""/>
  15.         <br/><br/>
  16.         <input type="submit" class="btn btn-default" value="Display Price"/>
  17.     </fieldset>
  18. </form>
  19.  
  20. get_price.php
  21. <?php
  22.  
  23.     require("../includes/config.php");
  24.  
  25.     $stock = lookup($_POST["symbol"]);
  26.    
  27.     if ($stock === false)
  28.     {
  29.         apologize("That's an invalid symbol!");
  30.     }
  31.    
  32.     render("display.php", ["stock" => $stock, "title" => "Stock Price"]);
  33.  
  34. ?>
  35.  
  36. display.php:
  37. <div>
  38.     <p>A share of <?= $stock["name"] ?> (<?= $stock["symbol"] ?>) is worth $<?= number_format($stock["price"], 2) ?>.</p>
  39. </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement