Johnny Lumberjack Johnny Lumberjack - 10 months ago 40
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.


You should have to use session:

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

and next page like:

$id = $_SESSION['id'];