bjr tt le monde,
en fait jessai de fair un formulaire de login par pass,et a chaque fois je recoi un message de Undefined variable!!!
voici le message d'erreur:
Notice: Undefined variable: user in c:\program files\easyphp1-8\www\fin\login.php on line 15
Notice: Undefined variable: user in c:\program files\easyphp1-8\www\fin\login.php on line 53
Notice: Undefined variable: pass in c:\program files\easyphp1-8\www\fin\login.php on line 53
je vous passe aussi le code:
<? session_start() ?>
<HTML>
<HEAD>
<TITLE>Login</TITLE>
</HEAD>
<BODY>
<H2>Login</H2>
<?
// keep hyperlinks in a string variable
$links = "<A
HREF='main.php'>Click here to proceed to the main
page</A><BR><BR><A HREF='logout.php'>Click here
to log out.</A>";
// check to see if details have been passed to the script by the form
if ($user!=NULL && $pass!=NULL) {
// if already logged in *as this user*, let them know, and show them the links.
// .. of course, if they are logged in as someone else, let them log in as a different user
if ($logged_in_user == $user) {
echo $user.", you are already logged in.<BR><BR>";
echo $links;
exit;
}
// connect to database and select 'userlist' database
$db = mysql_connect("localhost");
mysql_select_db("userlist", $db);
// check input variables against database
$result = mysql_query("SELECT * FROM users WHERE name = '".$user."'
AND password = PASSWORD('".$pass."')");
// in case of an error, throw up an error message and exit
if (!$result) {
echo "Sorry, there has been a technical hitch. We cannot enter your details.";
exit;
}
// greet valid user and show links
if (mysql_num_rows($result) > 0) {
$logged_in_user = $user;
session_register("logged_in_user");
echo "Welcome, ".$logged_in_user.". <BR><BR>";
echo $links;
exit;
// on invalid login, show user HTML form to login again
} else {
echo "Invalid login. Please try again.<BR><BR>";
}
// in case user only fills in one field, show error message and HTML form ..
} else if ($user || $pass) {
echo "Please fill in both fields.<BR><BR>";
}
?>
<FORM METHOD=POST ACTION="login.php">
Your username:
<INPUT NAME="user" TYPE=TEXT MAXLENGTH=20 SIZE=20>
<BR>
Your password:
<INPUT NAME="pass" TYPE=PASSWORD MAXLENGTH=10 SIZE=10>
<BR>
<INPUT TYPE=SUBMIT VALUE="Login">
</FORM>
</BODY>
</HTML>