kotak86
11-21-2011, 03:31 AM
Hi All
I am newbie in php and I want trying to make login application and I came to below issue:
1. In case of failed login how to redirect user in same page with meg like username and password do not match.
At this moment I have used header function but it simply redirect to my index.php(which is in fact login page)....but I want it with message....
Thanksif(isset($_POST['uname']) && isset($_POST['passwd']))
{
$usrname = $_POST['uname'];
$passwd = $_POST['passwd'];
$pass_haas =($passwd);
if(!empty ($usrname) && !empty($passwd))
{
$query = "SELECT * FROM `user_info` WHERE `uname` = '$usrname' AND `passwd` = '$pass_haas' ";
$query_run = mysql_query($query);
$query_num_rws = mysql_num_rows($query_run);
if($query_num_rws == Null)
{
header('Location:login.php');
}
else if ($query_num_rws == 1)
{
$user_id = mysql_fetch_assoc($query_run);
$user_name = $user_id['g_name'];
$_SESSION['g_name'] = $user_name;
header('Location:welcome.php');
}
}
else
{
echo 'You must supply user name and Password';
}
}
I am newbie in php and I want trying to make login application and I came to below issue:
1. In case of failed login how to redirect user in same page with meg like username and password do not match.
At this moment I have used header function but it simply redirect to my index.php(which is in fact login page)....but I want it with message....
Thanksif(isset($_POST['uname']) && isset($_POST['passwd']))
{
$usrname = $_POST['uname'];
$passwd = $_POST['passwd'];
$pass_haas =($passwd);
if(!empty ($usrname) && !empty($passwd))
{
$query = "SELECT * FROM `user_info` WHERE `uname` = '$usrname' AND `passwd` = '$pass_haas' ";
$query_run = mysql_query($query);
$query_num_rws = mysql_num_rows($query_run);
if($query_num_rws == Null)
{
header('Location:login.php');
}
else if ($query_num_rws == 1)
{
$user_id = mysql_fetch_assoc($query_run);
$user_name = $user_id['g_name'];
$_SESSION['g_name'] = $user_name;
header('Location:welcome.php');
}
}
else
{
echo 'You must supply user name and Password';
}
}