I'm using php 5 with mysql 4.1 i believe through godaddy.com I'm currently having a problem with my username and password script it always tells me incorrect username password which is the error I told it to send me if it couldn't find a match in the database so i would assume I have a problem with my php functions.
function BeInfoUser() {
$dbUser = "user";
$dbPass = "pass";
$dbhost = "blah.server.net";
$link = mysql_connect($dbhost, $dbUser, $dbPass);
return $link;
}
function UserLogin($username, $password){
$link = BeInfoUser();
mysql_select_db('BeInfo', $link);
$query = "SELECT * FROM user WHERE username = '$username' AND password = PASSWORD('$password')";
$result = mysql_query($query, $link);
$usercount = mysql_num_rows($result);
if($usercount == "0"){
mysql_close($link);
header('Location: http://www.beinformednow.org/user/login.php?error=1');
} else {
while($row = mysql_fetch_array($result)){
$userid = $row['userid'];
$username = $row['username'];
$level = $row['level'];
$_SESSION['userid'] = $userid;
$_SESSION['username'] = $username;
$_SESSION['level'] = $level;
}
mysql_close($link);
header('Location: http://www.beinformednow.org/index.php');
}
}
if(isset($_POST['username'])){
UserLogin($_POST['username'], $_POST['password']);
}
Any help would be appreciated I'm sure it's a stupid typo somewhere or an incorrect if statement or maybe even just improper use of functions.