www.webdeveloper.com
Results 1 to 5 of 5

Thread: how to set remind me function in login form

  1. #1
    Join Date
    Jul 2014
    Posts
    15

    Question how to set remind me function in login form

    Hi,

    My login form is running correctly.i want to add remind me function.please help me.

    html

    <form class="form-signin" role="form" id="form1" method="post" action="log.php">
    <h2 class="form-signin-heading text-center bluetxt">Sign In</h2>
    <input type="text" id="email1" class="form-control" name="email1" placeholder="Email address" autofocus /><br />
    <input type="text" id="pwd1" class="form-control" name="pwd1" placeholder="Password" value=""/><br/>
    <label class="checkbox">
    <input type="checkbox" value="remember" name="remember"> Remember me
    </label>
    <input type="submit" value="Login" onclick="ValidationLog()" style="color:#FFF;" class="btn btn-lg btn-primary btn-block"/>
    </form>

    PHP


    <?php

    $mail = $_POST['email1'];
    $pwd = $_POST['pwd1'];

    $con = mysql_connect("localhost","root","");
    if(!$con)
    {
    die('Could not connect:'.mysql_error());
    }
    mysql_select_db("biz",$con);
    if((($mail)&&($pwd))==""){
    header( 'Location:index.php' );
    }else{

    $result = mysql_query("SELECT mail,pw FROM reg WHERE mail = '$mail' AND pw = '$pwd'");
    $num_rows = mysql_num_rows($result);
    mysql_close($con);
    if($num_rows == 0)
    {

    }
    else{
    header( 'Location:user/' );

    }
    }

    ?>

    log.jpg

  2. #2
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    859
    1 - please post code properly using the tags as posted in the rules. ('php' and '/php' wrapped in square brackets to start and end your code section.)
    2 - please rewrite this code to use mysqli extension or pdo instead of the deprecated MySQL one
    3 - your if statement below:
    PHP Code:

     
    if((($mail)&&($pwd))=="")

    is rather confusing. A simpler statement is:
    PHP Code:
    if (!($mail && $pwd))

    to determine if one or both of the items are missing.
    Of even better (IMHO):
    PHP Code:
    if ($mail == '' || $pwd == '')

    to make your intent clearer.

    There are several other things wrong with your login approach but your question is really about something else. Whatever do you mean by "reminder"?

  3. #3
    Join Date
    Aug 2004
    Location
    Ankh-Morpork
    Posts
    19,537
    In fact, if you want to be really thorough (and I usually do ):
    PHP Code:
    if(
        !isset(
    $_POST['email1'])      or
        !isset(
    $_POST['pwd1'])        or
        
    trim($_POST['email1']) === '' or
        
    trim($_POST['pwd1']) === ''
    ) {
        
    header'Location:index.php' );
    }
    else {
        
    $mail $_POST['email1'];
        
    $pwd $_POST['pwd1'];
        
    // ... rest of code ...

    "Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
    ~ Terry Pratchett in Nation

    eBookworm.us

  4. #4
    Join Date
    Jul 2014
    Posts
    15
    thanks for your advice.what i want to do is when user click this remind me check box,system want to remind his email and password 1hour.please help.
    Attached Images Attached Images

  5. #5
    Join Date
    Jul 2013
    Location
    Voorheesville NY USA
    Posts
    859
    You must mean "REMEMBER ME", not remind me.

    In that case you could do it with a cookie. One for the remember me checkbox and one for the last userid that signed. Don't save the password though. Set your cookies expiration for as long as you want and then when the login script first runs check if the cookies exist.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

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



Recent Articles