Click to See Complete Forum and Search --> : Echo Error Message for Incorrect Login
bharanidharanit
Jan 21st, 2010, 08:22 AM
Hi,
I am having default.php and checklogin.php page.
When i login from default.php, it checks for correct login from checklogin .php.
When the login is correct, checklogin.php redirects to other page.
But if it is wrong, the page redirects to default.php page and here i want to echo as Incorrect Login.
I am already having Javascript Validation in default.php.
kows
Jan 21st, 2010, 08:51 AM
you can either:
set a query string variable
set a cookie
or set a session
that says the login was incorrect. then, check if this query string/cookie/session exists on your main page and display an error message if so.
bharanidharanit
Jan 21st, 2010, 09:14 AM
Ya Thankyou, which is the best one for displaying more errors..
kows
Jan 21st, 2010, 02:28 PM
it doesn't matter, that's why I gave you three different options.
bharanidharanit
Jan 22nd, 2010, 05:56 AM
Hi,
I used the sessions method, but it has some errors. Each and every time when the page loads the "Invalid Login" error message is displayed, even when the page is not posted to check the login.
checklogin.php coding
if($hash != $userdata['userpwd'])
{
$_SESSION['ErrorLogin'] = "Invalid Login";
header('Location: ../default.php');
//echo "Fails";
}
login.php coding
<?PHP
session_start();
if (isset($_SESSION['ErrorLogin']))
{
$error = $_SESSION['ErrorLogin'];
echo "$error";
}
manavo11
Jan 22nd, 2010, 06:51 AM
After you print it, you need to clear the session variable, otherwise it will stay set for as long as the session exists.
<?php
session_start();
if (isset($_SESSION['ErrorLogin']))
{
$error = $_SESSION['ErrorLogin'];
echo "$error";
unset($_SESSION['ErrorLogin']);
}
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.