wood burning stoves 2.0*
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 Android Security Essentials Live Lessons this week in the Android 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..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Redirecting to a login page with error messages
 
Similar Threads
Using Javascript, ajax and submit button in Custom tag file
Facing Issue in implementing Listeners and Filters
Form Based Authentication
Logout in JSF with Security managed by Glassfish v3.1
Login authentication using tomcat7