login error doesnt show up
Posted: Sun Aug 19, 2007 12:02 am
hi i am having problem with the error message on my login section..the error doesnt show up..well my login is located at the lower left of the homepage..i dont have a login page..users must login through my homepage...here's the code for the form...
that's where the user will input his/her login info..if the login is correct the account option will show up..and if the login is false then the login form will still show up..i call this file the main2.php which is being required by my index.php..
and here's the script for my login..this script can allow the user to login and can already determine if the user info is available or not..my problem here is to show the errormessage if the login is incorrect or incomplete..
ive tried putting return error$ at the end but login takes me into a blank php page..the error reporting is already turned on..please help me out..thanks
Code: Select all
<?
/* Include Files **********************/
require_once 'library/config.php';
/*************************************/
?>
<body>
<?php
if(isset($_SESSION['login_user']) && $_SESSION['login_user'] == 'ok'){
?>
<table cellpadding="3" cellspacing="0" border="0" width="140" style="font-family:sans-serif">
<tr>
<td align="center"><img src="include/myacc.jpg"></td>
</tr>
<tr>
<td class="accountmenu"><img src="icons/help_f2.png" width="22" height="22"><?php echo $_SESSION['login_name'];?></td>
</tr>
<tr>
<td class="accountmenu"><img src="icons/addedit.png" width="22" height="22"><a href="viewprofile.php" class="accmenu">View/Edit Profile</a></td>
</tr>
<tr>
<td class="accountmenu"><img src="icons/" width="22" height="22"><a href="orderhistory.php" class="accmenu">Orders</a></td>
</tr>
<tr>
<td class="accountmenu"><img src="icons/logout.png" width="22" height="22"><a href="logout.php" class="accmenu">Logout</a></td>
</tr>
</table>
<?php
}else{
$error = '';
?>
<form method="post" action="login2.php" onsubmit='return formValidator()' >
<?php echo $error; ?>
<table width="150" align="left" border="0" cellspacing="0" cellpadding="1">
<tr><td style="font-size:14px;font-weight:bolder" colspan="2" align="center">USER LOGIN</td></tr>
<tr><td style="font-size:12px">Username:</td><td><input type="text" name="user" size="10" id='user' maxlength="30"></td></tr>
<tr><td style="font-size:12px">Password:</td><td><input type="password" name="pass" size="10" id='pass' maxlength="30"></td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="sublogin" value="Login"></td></tr>
<tr><td align="center"><a href="registration.php" class="1">Join</a></td><td colspan="2" align="center"><a href="forgotpassword.php" class="1">Forgot Password</a></td></tr>
</table>
</form>
<?php
}
?>
</body>and here's the script for my login..this script can allow the user to login and can already determine if the user info is available or not..my problem here is to show the errormessage if the login is incorrect or incomplete..
Code: Select all
<?php
require_once 'library/config.php';
$error = '';
$userName = $_POST['user'];
$password = $_POST['pass'];
if($userName == '')
{
$error = "Invalid username";
}
else if($password == '')
{
$error = "Invalid password";
}
else
{
$sql = "SELECT * FROM tbl_customer WHERE Username = '$userName' AND Password = md5('$password')";
$result = dbQuery($sql);
if (dbNumRows($result) == 1)
{
$_SESSION['login_user']='ok';
$row = dbFetchAssoc($result);
$_SESSION['login_name'] = $row['Username'];
$_SESSION['login_id'] = $row['Customerno'];
}
else
{
$error = "Wrong username and password";
}
}
header('Location: index.php');
?>