Remove this URL string when login fails and simply show div error
Posted
by
Anagio
on Stack Overflow
See other posts from Stack Overflow
or by Anagio
Published on 2012-12-09T02:46:19Z
Indexed on
2012/12/09
17:04 UTC
Read the original article
Hit count: 236
php
|zend-framework
My developer built our registration page to display a div when logins failed based on a string in the URL.
When logins fail this is added to the URL /login?msg=invalid
The PHP in my login.phtml which displays the error messages based on the msg= parameter is
<?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."; }
?>
In the controller the redirect to that URL is
else //email id does not exist in our database
{
//redirecting back with invalid email(invalid) msg=invalid.
$this->_redirect($url."?msg=invalid");
}
I know there are a few other validation types for disabled accounts etc. I'm in the process of redesigning the entire interface and would like to get rid of this kind of validation so that the div tags display when logins fail but not show the URL strings.
If it matters the new div I want to display is
<div class="alert alert-error alert-login">
Email or password incorrect
</div>
I'd like to replace the php my self in my login.phtml and controller but not a good programmer. What can I replace $this->_redirect($url."?msg=invalid");
with so that no strings are added to the URL and display the appropriate div tags?
Thanks
© Stack Overflow or respective owner