This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes PHP and the fly likes Redirecting to a  login page with error messages Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Languages » PHP
Bookmark "Redirecting to a  login page with error messages" Watch "Redirecting to a  login page with error messages" New topic
Author

Redirecting to a login page with error messages

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 222

I have a login page having two fields username and password.

In the Login.html I have

<form method="post" action="checkLogin.php">
Username : <input type="text" name="username">
Password : <input type="password" name="password">
<input type="submit" value="Login">
</form>

In the checkLogin.php
I want to redirect to user to Login.html if username field or password field left blank.


How can I do that? How can I display error message also with redirection to Login.html.

Oracle Java Programmer , Oracle SQL Expert
Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 132

try with this

<?php
if(!isset($_POST['username']) || !isset($_POST['password']) || empty($_POST['username']) || empty($_POST['password'])){
header("Location:Login.html");
}
?>


Are you better than me? Then please show me my mistakes..
 
Consider Paul's rocket mass heater.
 
subject: Redirecting to a login page with error messages
 
Similar Threads
Facing Issue in implementing Listeners and Filters
Using Javascript, ajax and submit button in Custom tag file
Login authentication using tomcat7
Logout in JSF with Security managed by Glassfish v3.1
Form Based Authentication