File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 175

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.

Mahtab Alam (OCJP )
Blogs : alamsql.blogspot.in , alammahtab.blogspot.in
Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 131

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
Facing Issue in implementing Listeners and Filters
Login authentication using tomcat7
Form Based Authentication
Logout in JSF with Security managed by Glassfish v3.1
Using Javascript, ajax and submit button in Custom tag file