Advertisement
Jodyone

index.php

Apr 21st, 2014
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.09 KB | None | 0 0
  1. <?php
  2.  
  3.     // configuration
  4.    require("../includes/config.php");
  5.     // if form was submitted
  6.     if ($_SERVER["REQUEST_METHOD"] == "POST")
  7.     {
  8.         // validate submission
  9.         if (empty($_POST["username"]))
  10.         {
  11.             apologize("You must provide your username.");
  12.         }
  13.        if (empty($_POST["password"]))
  14.         {
  15.             apologize("You must provide your password.");
  16.         }
  17.         $positions = [];
  18.         foreach ($rows as $row)
  19.         {
  20.             $stock = lookup($row["symbol"]);
  21.             if ($stock !== false)
  22.             {  
  23.                 $positions[] = [
  24.                     "name" => $stock["name"],
  25.                     "price" => $stock["price"],
  26.                     "shares" => $row["shares"],
  27.                     "symbol"=> $row["symbol"]
  28.                     ];
  29.             }
  30.          }
  31.           render("portfolio.php", ['positions' => $positions, "title" => "portfolio"]);
  32.        
  33.     }
  34.         else
  35.         {
  36.         // render portfolio
  37.         render("portfolio.php", [ "title" => "portfolio"]);
  38.         }
  39.    
  40. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement