Php 当登录失败时删除此URL字符串,只显示div error
我的开发人员构建了我们的注册页面,以便根据URL中的字符串在登录失败时显示一个div 登录失败时,会将其添加到URLPhp 当登录失败时删除此URL字符串,只显示div error,php,zend-framework,Php,Zend Framework,我的开发人员构建了我们的注册页面,以便根据URL中的字符串在登录失败时显示一个div 登录失败时,会将其添加到URL/login?msg=invalid my login.phtml中基于msg=参数显示错误消息的PHP是 <?php $msg = ""; $msg = $_GET['msg']; if($msg==""){ $showMsg = ""; } elseif($msg=="invalid"){ $showMsg = ' <div class="a
/login?msg=invalid
my login.phtml中基于msg=参数显示错误消息的PHP是
<?php
$msg = "";
$msg = $_GET['msg'];
if($msg==""){ $showMsg = ""; }
elseif($msg=="invalid"){ $showMsg = ' <div class="alert alert-error">
<a class="close" data-dismiss="alert">×</a>
<strong>Error!</strong> Login or password is incorrect!
</div>'; }
elseif($msg=="disabled"){ $showMsg = "Your account has been disabled."; }
elseif($msg==2){ $showMsg = "Your account is not activated. Please check your email."; }
?>
我知道对于禁用的帐户等还有一些其他验证类型。我正在重新设计整个界面,并希望消除这种验证,以便在登录失败时显示div标记,但不显示URL字符串
如果重要的话,我想显示的新div是
<div class="alert alert-error alert-login">
Email or password incorrect
</div>
电子邮件或密码不正确
我想在login.phtml和controller中替换php我自己,但不是一个好的程序员。我可以用什么替换$this->\u重定向($url.?msg=invalid”)代码>以便不向URL添加任何字符串并显示相应的div标记
谢谢通过GET
参数传递msg
对我来说有点奇怪
请参阅此线程,讨论使用会话
、cookies
或数据库
向页面发送消息的其他方法
我不熟悉zend框架,但必须有一种方法在会话中设置“flash”消息。在控制器的登录操作中更改此选项
$this->_redirect($url."?msg=invalid");
到
然后将代码添加到login.phtml
<?php if ($this->message) :?>
<div class="alert alert-error alert-login">
Email or password incorrect
</div>
<? endif; ?>
... your form code there
电子邮件或密码不正确
... 你的表格代码在那里
这给了我一个错误致命错误:在/usr/share/php/Zend/View/Abstract.php中的路径(application/default/views/scripts/)中找不到未捕获的异常“Zend_View_exception”,消息为“script”user/login.phtml”(876):Zend_View_Abstract->脚本('user/login.phtm…)#1/usr/share/php/Zend/Controller/Action/Helper/ViewRenderer.php(897):Zend#u View_Abstract->render('user/login.phtm…'))#2
更长了……您有应用程序/default/views/scripts/user/login.phtml吗?
$this->view->message = $msg;
<?php if ($this->message) :?>
<div class="alert alert-error alert-login">
Email or password incorrect
</div>
<? endif; ?>
... your form code there