I'm having trouble with redirects in recipes. I get the "Redirect
Loop" browser error in certain contexts when I use the Redirect(page)
function. In other cases no redirect is executed.

Can anybody look at the 3 examples below and tell me why one works and
the other two do not? I'm running beta67.

The pages have a form to enter a page name and then create a new page etc.

This code causes the redirect loop error. I am running lighttpd and
Firefox 3, in case that is of significance:

---------------------------------------

<?php if (!defined('PmWiki')) exit();

$mypage = $_POST["mypage"];

        if (!$mypage) {
        $msg .= "  No input";
        }

        $FmtPV['$Msg'] = ' " '.$msg.' " ';
        $newpage = MakePageName("Users.Home", $mypage);

        if (PageExists($newpage)) {
        $msg .= "That page already exists: $mypage";
        $FmtPV['$Msg'] = '"'.$msg.'"';
        }


        else {
$mypage = $_POST["mypage"];
$mypage = ucfirst($mypage);
$new['text'] = "Enter new text here.\n\n";
$thispage = 'Users' . '.'. $mypage;
$urlfmt = '$PageUrl?action=edit';
PostPage("$thispage", $new, $new);
Redirect("$thispage", $urlfmt);
}

----------------------------------------

It is a browser error, not a pmwiki error text. A fixed page name like
Main.HomePage does not work either.


2) No error, but the redirect does not occur:

-------------------------------------------------------

<?php if (!defined('PmWiki')) exit();

$mypage = $_POST["mypage"];

        if (!$mypage) {
        $msg .= "  No input";
        }

        if (PageExists($newpage)) {
        $msg .= "That page already exists: $mypage";
        $FmtPV['$Msg'] = '"'.$msg.'"';
        }

        else {
        $mypage = ucfirst($mypage); # First letter needs to be upper-case
        $new['text'] = "Enter new text here.\n\n";
        $thispage = 'Users' . '.'. $mypage;
        PostPage($thispage, $new, $new);

        #Go to new page
        Redirect($thispage);
        }
------------------------------


3) This redirect works:

-------------------------------------------------------
<?php if (!defined('PmWiki')) exit();

$redirpage = $_POST['redirpage'];

if ( $redirpage ){
$FmtPV['$RedirMsg'] = "'Got page: $redirpage'";
$urlfmt = '$PageUrl?action=edit';
Redirect("Users.Home", $urlfmt);
}

else {
$FmtPV['$RedirMsg'] = '"No page"';
}
----------------


Many Thanks,

Marcus

_______________________________________________
pmwiki-users mailing list
[email protected]
http://www.pmichaud.com/mailman/listinfo/pmwiki-users

Reply via email to