This method uses a function to print the javascript for a given URL. It redirects via javascript.
<?
function UrlRedirect($url) {
$str = "
<html>
<script Language=\"JavaScript\">
window.location.href = \"$url\";
</script>
</html>
";
print $str;
}
$redirect="http://www.yourdomain.com/yourscript.php?var1=" . urlencode($var1) . "&var2=" . urlencode($var2);
UrlRedirect($redirect);
?>
This method will create the URL with only the variables you choose to specify. It then redirects via header.
<?
$redirect="http://www.yourdomain.com/yourscript.php?var1=" . urlencode($var1) . "&var2=" . urlencode($var2);
header("Location: $redirect");
?>
This Method will automatically create the URL with whatever variables (var1,var2...varN) were submitted to the script.
It then redirects via header.
<?
$redirect = "http://members.innercircle.org/login.php?redirect=" . urlencode(array_to_url($HTTP_GET_VARS));
header("Location: $redirect");
?>
For the two above messages to function, you need to use a function I picked up along the way called array_to_url :
function array_to_url( $values ){
if( !is_array( $values ) ) return false;
$url = '?';
reset( $values );
while( list( $k, $v ) = each( $values ) ){
if( !is_object( $v ) ){
if( is_array( $v ) ){
reset( $v );
while( list( $k2,$v2 ) = each( $v ) ){
$url .= $url == '' ? $k.'['.$k2.']='.urlencode( $v2 ) : '&'.$k.'['.$k2.']='.urlencode( $v2 );
}
}
else{
$url .= $url == '' ? "$k=" . urlencode( $v ) : "&$k=" . urlencode( $v );
}
}
}
return $url;
}