PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
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
<?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'); // this line is going to foward to index.php no matter what so lets change it to:
// the below:
if(!empty($error) && isset($error)){
echo $error;
exit;
} else {
header('Location: index.php');
}
?>
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[/quote]