Grundizer Grundizer - 8 months ago 49
PHP Question

Passing multiple variables to another page in url

I'm passing a variable to another page in a url using sessions like this but it seems that I can't concatenate another variable to the same url and retrieve it in the next page successfully

Page 1

$event_id = $_SESSION['event_id'];
echo $event_id;

$url = "http://localhost/main.php?email=" . $email_address . $event_id;

Page 2

if (isset($_GET['event_id'])) {
$event_id = $_GET['event_id'];}
echo $event_id;

echo $event_id
shows an error
Undefined variable
on page 2 but if I use just the
in the
like here

$url = "http://localhost/main.php?event_id=" . $event_id;

That works fine, but I need to be able to use both variables in the url so that page 2 can retrieve get them.


Use the ampersand & to glue variables together:

$url = "http://localhost/main.php?email=$email_address&event_id=$event_id";
//                               ^ start of vars      ^next var