Skip to main content
Explained what is actually happening and how to fix it.
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.

EDIT:

For quote.php, you should be doing something like this (in pseudo-code):

<?php

    // configuration

    // if user reached page via GET (as by clicking a link or via redirect)

        // else render form

    // else if user reached page via POST (as by submitting a form via POST)

        // validate submission
        // if symbol not in $_POST, apologize

        // Look up that stock
        
        // if symbol not found, apologize
        
        // else render quote
?>

You should look at the distribution code provided by CS50 Staff in the pset7.zip archive, and pay special attention to the parts that have comments like those in my pseudo-code above, especially the sections relating to // configuration, // if user reached page via GET, and // if user reached page via POST.

EDIT2:

Here's your problem: You need to use <form action="quote.php" method="post"> in your quote_form.php View. You can't use method="get", and here is why. When the quote.php Controller is reached via GET, it will render the quote_form.php View. That's why your code appears to just be refreshing the page. You want it to render the quote_template.php View instead, but only if it is responding to a form submission.

If this answers your question, be sure to click on the green checkmark to accept it. Or post an answer of your own and accept that -- I don't care, as long as you mark the question as answered to prevent it from becoming a zombie question!

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.

EDIT:

For quote.php, you should be doing something like this (in pseudo-code):

<?php

    // configuration

    // if user reached page via GET (as by clicking a link or via redirect)

        // else render form

    // else if user reached page via POST (as by submitting a form via POST)

        // validate submission
        // if symbol not in $_POST, apologize

        // Look up that stock
        
        // if symbol not found, apologize
        
        // else render quote
?>

You should look at the distribution code provided by CS50 Staff in the pset7.zip archive, and pay special attention to the parts that have comments like those in my pseudo-code above, especially the sections relating to // configuration, // if user reached page via GET, and // if user reached page via POST.

If this answers your question, be sure to click on the green checkmark to accept it. Or post an answer of your own and accept that -- I don't care, as long as you mark the question as answered to prevent it from becoming a zombie question!

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.

EDIT:

For quote.php, you should be doing something like this (in pseudo-code):

<?php

    // configuration

    // if user reached page via GET (as by clicking a link or via redirect)

        // else render form

    // else if user reached page via POST (as by submitting a form via POST)

        // validate submission
        // if symbol not in $_POST, apologize

        // Look up that stock
        
        // if symbol not found, apologize
        
        // else render quote
?>

You should look at the distribution code provided by CS50 Staff in the pset7.zip archive, and pay special attention to the parts that have comments like those in my pseudo-code above, especially the sections relating to // configuration, // if user reached page via GET, and // if user reached page via POST.

EDIT2:

Here's your problem: You need to use <form action="quote.php" method="post"> in your quote_form.php View. You can't use method="get", and here is why. When the quote.php Controller is reached via GET, it will render the quote_form.php View. That's why your code appears to just be refreshing the page. You want it to render the quote_template.php View instead, but only if it is responding to a form submission.

If this answers your question, be sure to click on the green checkmark to accept it. Or post an answer of your own and accept that -- I don't care, as long as you mark the question as answered to prevent it from becoming a zombie question!

More explicit hint.
Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.

EDIT:

For quote.php, you should be doing something like this (in pseudo-code):

<?php

    // configuration

    // if user reached page via GET (as by clicking a link or via redirect)

        // else render form

    // else if user reached page via POST (as by submitting a form via POST)

        // validate submission
        // if symbol not in $_POST, apologize

        // Look up that stock
        
        // if symbol not found, apologize
        
        // else render quote
?>

You should look at the distribution code provided by CS50 Staff in the pset7.zip archive, and pay special attention to the parts that have comments like those in my pseudo-code above, especially the sections relating to // configuration, // if user reached page via GET, and // if user reached page via POST.

If this answers your question, be sure to click on the green checkmark to accept it. Or post an answer of your own and accept that -- I don't care, as long as you mark the question as answered to prevent it from becoming a zombie question!

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.

EDIT:

For quote.php, you should be doing something like this (in pseudo-code):

<?php

    // configuration

    // if user reached page via GET (as by clicking a link or via redirect)

        // else render form

    // else if user reached page via POST (as by submitting a form via POST)

        // validate submission
        // if symbol not in $_POST, apologize

        // Look up that stock
        
        // if symbol not found, apologize
        
        // else render quote
?>

You should look at the distribution code provided by CS50 Staff in the pset7.zip archive, and pay special attention to the parts that have comments like those in my pseudo-code above, especially the sections relating to // configuration, // if user reached page via GET, and // if user reached page via POST.

If this answers your question, be sure to click on the green checkmark to accept it. Or post an answer of your own and accept that -- I don't care, as long as you mark the question as answered to prevent it from becoming a zombie question!

Source Link
hotwebmatter
  • 3.1k
  • 2
  • 14
  • 30

You definitely don't need to do this:

redirect("/../views/quote_template.php");

... after you have used the render() function.