View Full Version : Undefined index?

08-26-2009, 09:45 PM
Can someone explain to me why I am getting this error:

Notice: Undefined index: remember in C:\wamp\www\test\login.php on line 55

Here is the form I sent from:

<form class="border" name="login" id="login" action="login.php" method="post">
<ul id="loginul">
<li><label class="label"for="email">Email:&nbsp;</label></li>
<li><input name="email" class="floatRight" id="email" type="text" /></li>

<li><br /><br /><label class="label"for="password">Password:&nbsp;</label></li>
<li><input name="password" class="floatRight" id="password" type="password" />&nbsp;</li>
<li><br/><br/><label class="label"for="remember">Remember Me?&nbsp;</label></li>
<li><input name="remember" id="remember" type="checkbox" value="rememberMe" /></li>
<li><div class="center"><input type="submit" value="Login" id="login_btn" /></div></li>

And here is the php code I used to retreive the data:

echo 'You have succesfully logged in.';
else{echo 'Your email or password was entered incorrectly.';}

It seems I only get the error if I don't check the remember me checkbox.

The login() function seems not to work also when i don't check the box.

08-26-2009, 09:49 PM
well if the check box is not checked then it is not sent in the $_POST variables..
you should check whether the variable is defined like

$remember = 'Default value of remember';
} else {
$remember = $_POST['remember'];

08-26-2009, 09:53 PM
It didn't work. But thanks for the reply.

Edit: Nevermind I forgot the ! lol thanks