Codeigniter的重定向未传递变量数据

bla*_*elt 2 codeigniter codeigniter-2

我有一个表格来更新一些个人资料信息。在用户单击提交按钮my进行更改后,将其重定向到个人资料页面。

所以在将更新的信息插入数据库后,我有以下代码重定向到个人资料页面:

数据库查询在这里...

 redirect('studentprofile/get/$id');   
Run Code Online (Sandbox Code Playgroud)

$ id是配置文件ID,“ get”是函数,“ studentprofile”是控制器。但这根本不起作用。似乎“重定向”没有获得$ id的值。

当用户提交数据时,它显示错误消息“您提交的URI不允许使用字符”。网址看起来像这样

http:// localhost / sundial / studentprofile / get / $ id

您能告诉我我的脚本有什么问题吗?仅供参考,我正在使用Codeigniter

提前致谢 :)

Sea*_*udt 5

您需要将重定向路径字符串用双引号引起来:

redirect("studentprofile/get/$id");  
Run Code Online (Sandbox Code Playgroud)

或这样写:

redirect('studentprofile/get/'.$id);  
Run Code Online (Sandbox Code Playgroud)