wieso bekomm ich die variabel $worked nicht aus der funktion zurück ? Ich kanns, so scheint mir, drehen wie ich will es funktioniert nicht 

Code:
<?php
function login($username,$password) {
//trim
$username=trim($username);
$password=trim($password);
//var
$db="forum";
$table="user";
$password=md5($password);
$link=mysql_connect("localhost","root","xxx") or die (mysql_error());
$query="select * from $table";
$result=mysql_db_query($db,$query,$link) or die (mysql_error());
while ($row=mysql_fetch_array($result)) {
if (($row[password]==$password) && ($row[username]==$username)) {
setcookie(login,true);
setcookie(id,$row[ID]);
$worked=true;
}
}
return $worked;
}
login($array[username],$array[password])
?>
<html>
<head>
</head>
<body bgcolor="#444444">
<?php
if ($worked) {
print("login succesful");
} else {
print("login/password invalid !");
}
?>
</body>
</html>
Moderator



Kommentar