File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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

Redirecting to a login page with error messages

Mahtab Alam
Ranch Hand

Joined: Mar 28, 2012
Posts: 170

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">

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 : ,
Supun Lakshan Dissanayake
Ranch Hand

Joined: Oct 26, 2012
Posts: 131

try with this

if(!isset($_POST['username']) || !isset($_POST['password']) || empty($_POST['username']) || empty($_POST['password'])){

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