I'm very confused about the pset specification regarding quote.php. According to Zamyla, we first design a template, quote_form.php, asking the user about the symbol they want to look up. Then, we create a file in public, quote.php, where we declare variables for stock and s for an associative array

$stock = lookup($_POST["symbol"]);
$s = lookup("AAPL");

Then, we create another template, quote.php, where we display quote (how do we do that?), ensure the stock is valid and print its price.

Is my understanding of this function correct? Please correct me if I'm wrong.

I tried the above and I get a blank page when I try to open pset7/quote.php in a browser.

1 Answer 1


Your usage of lookup is correct. Realize that lookup returns an array, so you want to be able to access they key value you want, whether name or price, from $stock (btw be sure it can handle "symbol" user input whether inputted in lower or upper caps). As for rendering the quote page, you can follow the way way login.php renders login_form.php as discussed in pset specs.

  • @ronga Okay. Do we still put <form action="quote.php" method="post"> on the second template, quote.php?
    – hunter
    Aug 30, 2014 at 16:49
  • Nevermind. I figured it out. Thanks :D
    – hunter
    Aug 30, 2014 at 19:03
  • I am having the same issue. Could you tell us what the problem was?
    – JAraujo
    Sep 12, 2014 at 14:03
  • I am having problems with this too, I have got the lookup to work, but I don't know how to access the array from the second template. The variables don't exist in that .php file...
    – aharris
    Nov 6, 2014 at 1:53
  • @aharris, you can't access the variables from the other template as they're out of scope. As mentioned in my original comment above, you should look at the login file and associated template. login_form.php is able to access the variables in login.php through the use of a function in the latter (i.e. the function passes the variables to the former, bringing them into local scope).
    – ronga
    Nov 6, 2014 at 2:19

You must log in to answer this question.

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