Re: A few newbie questions
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.php archive

Re: A few newbie questions

From: richard <richard@localhost.localdomain>
Date: Sat Jul 30 2005 - 10:08:37 CEST

On 2005-07-20, SOR <webmaster@sparesorrepair.co.uk.INVALID> wrote:
><comp.lang.php , Ken Robinson , kenrbnsn@rbnsn.com>
><1121803119.844840.154330@g47g2000cwa.googlegroups.com>
><19 Jul 2005 12:58:39 -0700>
>
>> > instead of include - how do I tell it to goto the new page like clicking
>> > on a link
>>
>> Use the header() function.
>
> It sucks there isnt a easy to use command in php like
> webpage('filename.php') .

/**
* Sends user to a page
*
* @param string $sGoToPage - url to a page
* @param array $aOnwardVars - array of key=>value to pass to next page
* @return null does not return.
**/
function webpage($sGoToPage,$aOnwardVars)
{
        header('Location: '
                .str_replace('&amp;','&',$sGoToPage.'?'.URLParams($aOnwardVars))
                );
        
        // In case the browser can't handle that or we've
        // output already so header's don't work..
        print '<html><head><script type="text/javascript">self.location="'
        . $sGoToPage.'?'.URLParams($aOnwardVars). '";</script></head>';
        
        // And in case we've got dumb browser..
        print '<body>Moving to the next page... <a href="'
         . $sGoToPage.'?'.URLParams($aOnwardVars) . '"
        alt="Please click here to continue"
        TITLE="Please click here to continue">
        Please click here if it does not load automatically.
        </a></body></html>';
        exit; // STOP PROCESSING HERE.

}
function URLParams($aOnwardVars)
{
        $aParamParts=array();
        foreach($aOnwardVars as $key=>$val)
                $aParamParts[] = $key .'='. rawurlencode($val);
        return implode('&amp;',$aParamParts);
}
Received on Tue Oct 18 02:06:20 2005