Johnny Lumberjack Johnny Lumberjack - 1 year ago 84
PHP Question

PHP - How to pass GET values through header?

I'm trying to pass the

value through the
function, but it seems to not work. because I can't get the value in the page redirecting to.

Here is the code snippet I'm working on:

$url = BASE_URL . 'send.php?id=' . $id;
header("Location: $url");

But when I try to get this value in the other file, doing
$id = $_GET['id']
I get a PHP Notice:

PHP Notice: Undefined index: id in (MY_FILE_PATH) on line 5

Can someone help me? Thanks.

Answer Source

You should have to use session:

$_SESSION['id'] = $_GET['id'];
header('Location: $url');

and next page like:

$id = $_SESSION['id'];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download