Fork me on GitHub

pnRedirect  Bottom

Go to page [-1] 1 - 2:

  • Mark: If I echo the statement I get "Resource id #<number>".. no indication of any errors

    ctimmer: So are you saying that PHP can see code written *after* the redirect? I tried redirecting and writing all kinds of nasty stuff right after the redirect statement, but nothing would nullify it or even be seen at all by PHP. So while the redirect was working, I could return true, false or echo something and it wouldn't matter</number>
  • The redirect sends a response back to the browser 'redirecting' it to another URL. The PHP code continues, but depending on how the browser handles the redirect, is most likely no longer be connected to the browser. At this point, any output from this instance would only be writing to a broken connection.
  • Okay, I thought PHP stopped - thanks ctimmer! :)
  • Is there any way to include the current form data when using pnRedirect?

    ie.


    list($var1, $var2) = pnVarCleanFromInput('var1','var2');

    if (!isset($var2) || empty($var2)) {
    pnSessionSetVar('errormsg', pnVarPrepHTMLDisplay("var2 empty"));
    return pnRedirect(pnModURL('Example', 'user', 'new','var2'));
    }
  • Use

    Code

    pnRedirect(pnModURL('Example', 'user', 'new',array('var2' => $var2,'var1' => $var1)))


    --
    cyber_wolf
    www.bkbsolutions.com - My Zikula module development site.
  • Just wondering... But I noticed there aren't any header sent with pnRedirect. Which means there's a 302 Found send. This means SE's will index the old URL, instead of they're gonna index the URL which is redirected too.

    Wouldn't it be wiser to send out 301 Moved Permanent headers befor a location?

    Why would we want to redirect, but not tell the client the page has moved?
  • Hunkpapa,


    Quote

    I have no idea why but pnRedirect does absolutely nothing for me:
    pnRedirect('http://www.postnuke.com');


    I had a similar problem a while back and worked out this bit of code for tracking it down.

    Code

    function Exams_admin_test()
    {
        if (headers_sent($filename, $linename)) {
                echo "headers are already sent in $filename at $linename";
        } else {
                pnRedirect(pnModURL('Exams', 'admin', 'viewitems'));
                return true;
        }
    }


    By including the $filename and $linename in headers sent, it points you to the problem file. In my case it was a bit of white space in an included file. When I removed that space, the problem disappeared. You might want to try this and see if you can find the problem.



    edited by: Paustian, Dec 03, 2006 - 03:31 AM

Go to page [-1] 1 - 2:

This list is based on users active over the last 60 minutes.