开发者

form select menu using php to jump to a page but goes into infinate loop

开发者 https://www.devze.com 2023-03-22 04:51 出处:网络
(Have ammended this question to show the redirect code) I am using a select menu in a simple fo开发者_开发问答rm for a bus tours site to allow users to select an option and have a new page load using

(Have ammended this question to show the redirect code)

I am using a select menu in a simple fo开发者_开发问答rm for a bus tours site to allow users to select an option and have a new page load using php based on what they select. This works fine but if the user clicks submit when the first value is selected eg 'select a bus tour' it should go nowhere but instead it seems to go into a loop. Firefox gives this error:

http://hairycoo.nsdesign7.net/tour//

here is the form code:

$thisTour = new tour($_GET['id']);
$tourData = $thisTour->getData();

if ( !isset($_GET['pagetile']) )
{
ob_get_clean();
header('Location: /tour/'.urlencode($tourData->tours_title).'/'.$_GET['id']);
exit();
}

Thanks! Paul


Your site seems to be stuck in a redirect loop, I went to the URL and there was nothing to see. I suspect this may be your issue:

If you have a page redirecting to itself in the absence of a required $_POST value, make sure you only do it if $_POST data is actually present. The $_POST data will then expire after the first redirect. Example:

if ( ! empty($_POST)) // <--- make sure there is post data
{
    if ( ! isset($_POST['some_required_value']))
    {
        header('Location: my/url'); // Redirect back
    }
    else
    {
        // Process the data
    }
}

The content of the form is not related, feel free to edit your question and post the code that preforms the redirect if this is still giving you trouble.

0

精彩评论

暂无评论...
验证码 换一张
取 消