Smarty 中未定义的变量
我正在使用 DooPHP,并为我的表单生成一个安全令牌,以防止 csrf 攻击。我将令牌分配给 smarty 变量,我可以看到它显示在源代码中 - 因此它可用。但是,当我提交表单时,它会抛出一个错误:
Undefined variable: secToken
See file C:\wamp\www\korysdoo\protected\class\smarty\sysplugins\smarty_internal_data.php
Error on line 291 $x = $$_variable;
有什么想法可能是错误的吗?我可以看到 secToken 的值被发布到适当的函数。
I'm using DooPHP and I'm generating a security token for my form to protect against csrf attacks. I'm assigning the token to a smarty variable and I can see that it is displayed in the source - so it is available. When I submit the form though, it throws out an error saying:
Undefined variable: secToken
See file C:\wamp\www\korysdoo\protected\class\smarty\sysplugins\smarty_internal_data.php
Error on line 291 $x = $_variable;
Any ideas what can be wrong? I can see that the value of secToken is being posted to an appropriate function.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要先向 smarty 注册该变量聪明人可以利用它。
您已经为显示表单的模板执行了此操作,但可能没有为显示提交结果的模板执行此操作。然后也将其添加到结果模板中。
You need to register that variable with smarty before smarty can make use of it.
You've done that for the template displaying the form, but probably not for the template where you display the submission result. Add it for the result template as well then.
问题解决了。虽然它躺在别的地方。当登录不成功时(由于不同的原因,确实如此),我显示相同的登录表单模板,而没有再次分配安全令牌。
Problem solved. Though it was lying somewhere else. When the login was unsuccessful (which it was, for different reasons), I was displaying the same login form template without assigning the security token again.