Folgender Code ist für das einloggen zuständig
Code: Alles auswählen
<?php
//Require
require("config.inc.php");
//Check to see if the user's loged in.
if($QUERY_STRING=='login'){process();}
elseif(empty($HTTP_COOKIE_VARS['username'])){login();}
elseif($QUERY_STRING=='logout'){logout();}
else{loggedin();}
//Login Page
function login() {
global $PHP_SELF;
$tbl_data = style_settings();
load_top();
?>
<center>
<font face="<? echo $tbl_data['font'] ?>" size="2">
<form action="<? echo "$PHP_SELF?login"; ?>" method=POST>
Username:<br><input type=text name=username><br>
Password:<br><input type=password name=password><br>
<input type=submit value="Login">
</form>
</font>
</center>
<?php
load_bottom();
}
//Do the login
function process() {
global $username,$password,$tables;
$password=md5($password);
$result=mysql_query("SELECT * FROM $tables[user] WHERE username='$username' AND password='$password'");
$number=mysql_numrows($result);
if($number!=1){log_error("Bad Username or Password");}
$lifetime = time() + 86400 * 356;
setcookie("username",$username, $lifetime);
setcookie("user_id",mysql_result($result,0,"id"), $lifetime);
header("Location: index.php?top_message=Logged In");
}
//Logout User
function logout() {
setcookie("username");
setcookie("user_id");
header("Location: index.php?top_message=Logged Out");
}
//Logged In Function
function loggedin() {
load_top();
print_text("You are already logged in.<br><a href=\"log.php?logout\">Click Here to Log Out</a>");
load_bottom();
}
//Error for Login
function log_error($text) {
load_top();
print_text($text);
load_bottom();
exit;
}
?>
Wenn ich mich jetzt mit meinem Usernamen und Passwort einloggen will kommt die von mir bestimmte Fehlermeldung "Bad Username or Password" obwohl die Daten stimmen.
Die stimmen hundertprozentig. Ist alles in der MysqlDB richtig eingetragen der User ... kann mir jemand helfen und sagen, was da falsch sein könnte?