I am doing the Harvards building dynamic websites called CS-75 (also could be called E-75), because someone told me about it and I just thought might as well, it is all learning 🙂 even if allot of it you may already know.
As from the previous post, most of this page is in similar in nature it is just displaying data to the user that was built up from the classes files.
So to buy some stock, what this page will do is wait for the user to type in a stock symbol and then use the stock class to get the data back from that symbol and then have another input that will allow the user to buy some of that stock, also if the user clicks on the link it will display at the bottom of the page new items about the stock itself.
BuyStock($_SESSION["username"], $stockID, $stockAmount);
}
if (isset($_REQUEST["searchSymbol"]))
{
if (strlen($_REQUEST["searchSymbol"]) >=3)
$result = $theStock->GetStocksFromYahoo(strtoupper($_REQUEST["searchSymbol"]));
}
HTMLHeader("Buy some stock, search and buy");
if (isset ($stockPurchased)) {
echo "";
if ($stockPurchased >0 )
echo "Stock was purchased ($stockID amount of $StockAmount total price of $stockPurchased each price was ". number_format($stockPurchased / $stockAmount,2).")";
else
echo "Problem with purchasing the stock, please email the error above to the support team";
echo "
";
}
?>
Your present cash flow is
GetCash($_SESSION["username"]),2); HTMLFooter(); ?>To view the stock details of the user, I just display the stock that the user has from data once again from the stock class, which also includes the current price of the stock. There is a checkbox that will allow the user to sell some of there stock (if they have any!!) and once again use the stock class to sell the stock and update the tables in the database.
$value)
{
if (strpos($key, "remove_") === 0)
$theStock->SellStock($_SESSION["username"], $value);
if ($key=="stock")
$getStock = $value;
}
HTMLHeader("The details of your account");
?>
The stocks that the user has
Your present cash flow is
GetCash($_SESSION["username"]),2); echo "Your cash + investments
" . number_format($theUser->GetCash($_SESSION["username"]) + $totalValue,2); if (isset($getStock)) { echo "$getStock more information
Date | Title/Link |
{$stockDetailsArray[$i]["Date"]} | {$stockDetailsArray[$i]["Title"]}"; } echo " |
The last part is the change of the password, which just will use the user class to update the users password to the requested input from the change password page.
ChangePassword($_SESSION["username"], $_REQUEST["password1"]);
else
$notSamePassword = true;
}
if (!isset($_SESSION["authenticated"]))
{
header("Location: /index.php");
exit;
}
HTMLHeader("Change password",true);
if (isset($error))
{
if ($error)
echo "Password updated";
else
echo "Cannot update the password, please contact the system admin";
}
if (isset($notSamePassword))
echo "Passwords are not the same";
?>
The actual pages that are displayed to the user are all very basic as them selves, but the actual logic and formula are all within the classes that is the gold dust as such, since it is one point of checking and also one file to update if there is a update to the yahoo etc stocks details, because would have to update the different pages that display the stocks and that is not good for testing and also updating.