Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

php Header to redirect when post - redirect troubles

header('Location: ../pages/my-files.php?parent_id=' . $_POST['parent_id']);

The above needs to redirect the user when a form is submitted, using a hidden variable for _parent_id.

However for some reason the user is bieng redirected (or seems to be by looking at the browser URL) to simply ../pages/my-files.php

Any ideas?

PS. Im certain that $_POST['parent_id'] has a value.

like image 453
Aleski Avatar asked May 18 '26 09:05

Aleski


1 Answers

Have you tried to encode $_POST['parent_id'] for use in a url?

header('Location: ../pages/my-files.php?parent_id=' . rawurlencode($_POST['parent_id']));

But it must be something else because your code looks ok. Are you shure that you are redirecting from that point and not from another? Have you tried putting a die() just before that redirection?Most of the times i had your problem i wasn't redirecting from the right place!

like image 97
Nicola Peluchetti Avatar answered May 19 '26 22:05

Nicola Peluchetti



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!