0
<?php

    // configuration
        require("../includes/config.php");
    if ($_SERVER["REQUEST_METHOD"] == "GET")
    {
        // else render form
        render("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")
    {
    if(empty($_POST["symbol"]))
        apologize("Please enter the stock symbol.");
    else
    {
        $stock = lookup($_POST["symbol"]);
        if(!$stock)
            apologize("Invalid symbol.");
        else

        render("quote_output.php", ["price" => number_format($stock["price"], 2, '.', ',')]);


    }
    }
?>
//quote_output.php
<p>Price:<?=htmlspecialchars($message)?></p>
2
  • So if we're reading this correctly, quote_output.php is contained in a separate file that is so-named, and consists solely of the line <p>Price:<?=htmlspecialchars($message)?></p> ?
    – ronga
    Jun 26, 2016 at 13:38
  • Yes.Just like apology.php. Jun 26, 2016 at 18:43

1 Answer 1

0

Assuming you have the necessary headers (which you don't show in the above code snippet) in your quote_output.php file, your problem is the fact that it contains an undefined variable $message, which was not passed in via your render function.

3
  • Could you be a little specific regarding those headers(i have just one line of code in quote_output)? apology.php did not contain anything.And i surmise $message is passed on by the render function itself. Jun 27, 2016 at 18:29
  • Your browser will not recognize this as html 5 unless your code starts with the <!DOCTYPE html> header and ends with </html>. Also, what does $message contain? It's not defined in quote, nor do you pass it in via render, as you did with price.
    – ronga
    Jun 28, 2016 at 1:50
  • It works now.Should be &price. Jul 4, 2016 at 19:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .