Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Jul 2009
    Posts
    52
    Thanks
    6
    Thanked 1 Time in 1 Post

    Undefined index?

    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:
    Code:
    <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>
                        </ul>
        			</form>
    And here is the php code I used to retreive the data:

    PHP Code:
    $email=$_POST["email"];
        
    $password=$_POST["password"];
        
    $remember=$_POST["remember"];
                
    $bools=login($email,$password,$remember);
                if(
    $bools){
                    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.

  • #2
    New Coder
    Join Date
    Aug 2009
    Posts
    26
    Thanks
    1
    Thanked 3 Times in 3 Posts
    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
    PHP Code:
    if(!isset($_POST['remember'])){
    $remember 'Default value of remember';
    } else {
    $remember $_POST['remember'];

    Last edited by tailender1; 08-26-2009 at 09:49 PM. Reason: code wrap

  • Users who have thanked tailender1 for this post:

    firetag (08-26-2009)

  • #3
    New Coder
    Join Date
    Jul 2009
    Posts
    52
    Thanks
    6
    Thanked 1 Time in 1 Post
    It didn't work. But thanks for the reply.

    Edit: Nevermind I forgot the ! lol thanks
    Last edited by firetag; 08-26-2009 at 09:57 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •