将多个变量传递到url中的另一个页面 [英] Passing multiple variables to another page in url
本文介绍了将多个变量传递到url中的另一个页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用类似的会话将变量传递到url中的另一个页面,但是看来我无法将另一个变量连接到相同的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
第1页
session_start();
$event_id = $_SESSION['event_id'];
echo $event_id;
$url = "http://localhost/main.php?email=" . $email_address . $event_id;
第2页
if (isset($_GET['event_id'])) {
$event_id = $_GET['event_id'];}
echo $event_id;
echo $event_id
在第2页上显示错误Undefined variable
,但如果我仅在$url
中使用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;
这很好,但是我需要能够在url中使用这两个变量,以便页面2可以检索得到它们.
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
这篇关于将多个变量传递到url中的另一个页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文