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
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: 249

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 , Oracle Java Web Component Developer
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..
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Redirecting to a login page with error messages