How to pass multiple variables to another page in url

0 votes

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

session_start();
$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 event_id in the $url 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.

Nov 23, 2020 in PHP by kartik
• 37,520 points
22,165 views

1 answer to this question.

0 votes

Hello @kartik,

Use the ampersand & to glue variables together:

$url = "http://localhost/main.php?email=$email_address&event_id=$event_id";
//                               ^ start of vars      ^next var
answered Nov 23, 2020 by Niroj
• 82,840 points
How to pass multiple variables to another page in url  | Edureka Community
dzpflevzt http://www.gwa8g8d4u7hk913co4k44f2b8man9578s.org/
[url=http://www.gwa8g8d4u7hk913co4k44f2b8man9578s.org/]udzpflevzt[/url]
<a href="http://www.gwa8g8d4u7hk913co4k44f2b8man9578s.org/">adzpflevzt</a>

Related Questions In PHP

0 votes
1 answer

How to concatenate text from multiple rows into a single text string in SQL server?

Hello @kartik, Use COALESCE: DECLARE @Names VARCHAR(8000) SELECT @Names = ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,840 points
3,077 views
0 votes
1 answer

How to Insert multiple rows in a single SQL query?

Hello @kartik, In SQL Server you can insert ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,840 points
4,384 views
0 votes
1 answer

How to select all records from one table that do not exist in another table?

Hello @kartik, You can either do like this: SELECT ...READ MORE

answered Jul 21, 2020 in PHP by Niroj
• 82,840 points
53,162 views
0 votes
1 answer

How to delete from multiple tables in MySQL?

Hello @kartik, Use a JOIN in the DELETE statement. DELETE p, pa ...READ MORE

answered Aug 26, 2020 in PHP by Niroj
• 82,840 points
3,815 views
+1 vote
1 answer

How to make anchor tag with routing using Laravel?

Hey @kartik, First you have to go to ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
23,012 views
0 votes
1 answer

What is redirection in Laravel?

Named route is used to give specific ...READ MORE

answered Mar 18, 2020 in Laravel by Niroj
• 82,840 points
2,995 views
0 votes
1 answer

How to install Laravel via composer?

Hello, This is simple you just need to ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
2,918 views
+1 vote
1 answer

What are named routes in Laravel and How can specify route names for controller actions?

Hey @kartik, Named routing is another amazing feature of ...READ MORE

answered Mar 23, 2020 in Laravel by Niroj
• 82,840 points
44,693 views
0 votes
1 answer

How to Debug Variables like in PHP var_dump()?

Hello @kartik, Try out with the Smarty Session: {$smarty.session|@debug_print_var} or {$smarty.session|@print_r} To ...READ MORE

answered Apr 20, 2020 in PHP by Niroj
• 82,840 points
1,536 views
0 votes
1 answer

How to get Redux Form data in another Component?

Hello @kartik, What you need to do is ...READ MORE

answered Jun 1, 2020 in PHP by Niroj
• 82,840 points
4,161 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP