通过头文件传递php变量 [英] passing php variables through header
问题描述
我想通过标头传递一个变量。在我的系统中,用户停留在个人资料页面上并点击链接填写并提交表格。提交表单时,页面将重定向到配置文件页面。当我的个人资料页面显示时,会员ID已经丢失,所以它不显示会员详细信息。我想要做的是在重定向发生时传递成员ID。
$ b $ pre $ 函数redirect_to($ location = NULL){
if($ location!= NULL){
标题( 位置:{$位置});
出口;
}
}
redirect_to('member_profile.php');
我想要做的是这个
redirect_to的( 'member_profile.php ID = $ mselcted_memberI?');
您正在使用单引号 '
这将使它成为一个字符串,而是使用。
来连接,而不是
redirect_to的( 'member_profile.php ID =?' $ mselcted_memberI。);
另外,您不需要大括号 {}
here
header(Location:$ location);
I want to pass a variable through header. In my system the user stays on the profile page and click on a link to fill and submit a form. When the form is submitted the page redirect to the profile page. When I the profile page displayed the member id has lost, so it don't display the member details. What I want to do is pass the member id when redirecting happens.
function redirect_to($location = NULL){
if($location != NULL){
header("Location:{$location}");
exit;
}
}
redirect_to('member_profile.php');
what I am trying to do is this
redirect_to('member_profile.php?id=$mselcted_memberI');
You are using single quotes '
which will make it a literal string, instead, concatenate that using a .
instead
redirect_to('member_profile.php?id='.$mselcted_memberI);
Also, you don't require braces {}
here
header("Location:$location");
这篇关于通过头文件传递php变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!