I have set up a template form that sends the symbol selected by the user to the controller.
I cannot get the form to show when I request the page.
Here is my code for the form:
<form action="sell.php" method="post">
<fieldset>
<div class="form-group">
<select class="form-control" name="symbol">
<option value=""> </option>
<?php$rows=query("SELECT * FROM portfolio WHERE id=?" , $SESSION["id"]);?>
<?php foreach $rows as $row:?>
print("<option value=\"{$row["symbol"]}\">{$row["symbol"]}</option>");
<?php end foreach ?>
</select>
</div>
<div class="form-group">
<button type="sell" class="btn btn-default">Sell</button>
</div>
</fieldset>
</form>
This is my code for the controller:
<?php
//Configure page
require("..//includes/config.php");
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
//check if the field was filled
if(empty($_POST["symbol"]))
{
apologize("You must submit a symbol");
}
else
{
//code to deal with successful post
}
else
{
apologize("There was an issue confirming your sale.");
}
?>
When I request the page in my browser is takes me straight to the last line indicating that the post was not successful but I cannot decipher why that is.