Hi, I’m putting the finishing touches on a login script, which searches for the given username in the mysql database, and checks if the password matches. If the password matches it redirects to the members area, otherwise it redirects back to the login page.
However, if the username is not a correct username, it prints out an error instead of redirecting to the loginpage again. How can I stop it producing an error if it can’t find the username in the database?
This is part of the login script’s source:
[code=php]
$server=mysql_connect($host,$user,$pass);
mysql_select_db($db_name);
$usernamea=$_POST[‘username’];
$passworda=$_POST[‘password’];
$query=”SELECT password FROM users WHERE username=”$usernamea””;
$result=mysql_query($query);
if($result)
{
$result=mysql_result($result,0);
if($result==$passworda)
{
$query=”UPDATE users SET online=’true'”;
mysql_query($query);
redirectPage(“http://www.google.com”);
}
else
{
redirectPage(“loginpage.php?redir=2”);
}
}
else
{
redirectPage(“loginpage.php?redir=1”);
}