将多个变量传递给 url 中的另一个页面 [英] Passing multiple variables to another page in url

查看:32
本文介绍了将多个变量传递给 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/code> 就像这里

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆