0

quotes.php

<?php

    // configuration
    require("../includes/config.php");
      if ($_SERVER["REQUEST_METHOD"] == "GET")
    {
       //do something

    // else render form
           render("../views/quote_form.php", ["title"=>"Quote"]);
    }
     // else if user reached page via POST (as by submitting a form via POST)
    else if ($_SERVER["REQUEST_METHOD"] == "POST")
    {
      //Check if symbol attribute is empty
      if(empty($_POST["symbol"]))
        apologize("The symbol cannot be empty");
      else
        {
            $stock = lookup($_POST["symbol"]);
            //Check if symbol is invalid
            if(!$stock)
                {
                  apologize("The symbol is invalid");
                }
            else
                $quote =["name"=>$stock["name"],"symbol"=>$symbol,"price"=>$stock["price"]];
                render("../views/quote_form.php", ["title"=>"Quote"]);
        }
    }

?>    

quotes_form.php

<?php
// echo "The share" .$quote["name"]."(" .$quote["symbol"] ") costs:$".number_format($quote["price"],2,'.',');
 echo"A share of".$quote['name']."(".$quote['symbol'].")     costs : $".number_format($quote['price'],2,'.',',');

?>

Error encountered

Invalid_message

Getting a new error

2
  • Reread helpers section in the doc. Then change this line render("../views/quote_form.php", ["title"=>"Quote"]); appropriately. Jul 21 '16 at 16:43
  • I have changed it to render ("../views/quote_form.php", [quote => $quote,"title"=>"Quote"]); But I still encounter the same error. Also in quote_form.php, I have used the print_r function but this also turns out to be futile. Jul 22 '16 at 4:54

You must log in to answer this question.

Browse other questions tagged .