Tomek Wojtek Tomek Wojtek - 1 year ago 68
PHP Question

redirect doesn't include whole querystring

I'm trying to redirect, but it doesn't include all the parameters in the url

if (!empty($_POST['nazwauzytkownika']) && $_POST['haslo'])


if (isset($_GET['redirect']))
$redirect = $_GET['redirect'];
$redirect = 'http://*****.pl/konto/?a=powitanie';

header("Location: $redirect");


, it only redirects to

Answer Source

it is not redirect problem but url problem
every GET parameter should be urlencoded

$redirect = rawurlencode($redirect);
<a href="some.php?redirect=<?=$redirect?>">

then you will have your redirect param inact and can use it for redirect.

though it's considered as bad practice as your script can be used for phishing links.

it's better to pass just url identifier, and then read an url itself from db/session/whatever server side storage

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download