PHP Redirect

Status
Not open for further replies.

eclipsenetworkz

New member
Mar 12, 2007
87
1
0
I have this code on my redirect page

<?php

foreach($_POST as $key => $value) {
$$key = $value;
}
foreach($_GET as $key => $value) {
$$key = $value;
}
$w = $_GET['w'];

?>

<?php
header('location:<? echo $w; ?>');
?>

The w is a url parameter. What is wrong. The url's are dynamically generated that's why it has to be passed as a parameter and echo'd. What is wrong. This doesn't work to redirect.
 


Try this instead:

<?php

foreach($_POSTas $key => $value) {
$$key = $value;
}
foreach($_GET as $key => $value) {
$$key = $value;
}
$w = $_GET['w'];

if ($w <> "") {
header('Location: ' . $w);
} else {
// error no parameter
}
?>

Mubs
 
I was having trouble getting the code to work in the seperate php tags and I have no idea why. This worked for me though:

Code:
<?php

foreach($_POST as $key => $value) {
$$key = $value;
}
foreach($_GET as $key => $value) {
$$key = $value;
}
$w = $_GET['w'];

header("Location: " . $w);

?>
 
1.You might want to do a meta redirect, so you wont pass referrer.

2. I don't see the point of those foreach loops

3. theres no escaping no validations nada, hope your not passing anything to sql.
 
Status
Not open for further replies.