dtfo55908 2015-09-15 10:14
浏览 62

用户名和密码未在cookie中设置

i want to set username and password on check of remember me check box and destoy the cookie on uncheck of check box but when i click on remember me check box and check the output of cookie then there is no cookie set(no output). I want to show my code please check and tell me where i did the mistake:

<div class="col-md-5">
    <h4>Login</h4>
    <form  method="post" action="" name="customer_form">   
        <?php 
            if($danger_msg_client){
            
                ?>
                <div class="alert alert-danger">
                    <strong><?php echo $danger_msg_client;?></strong>
                </div>
                <?php
            }
        ?>
        <div class="form-group">
            <div class="input-group"> <span class="input-group-addon"><i class="fa fa-user"></i></span>
                <input type="text" class="form-control" name="client_username" id="client_username" placeholder="Email ID" required="required" value="<?php echo $_COOKIE['username']; ?>"/>
            </div>
        </div>
        <div class="form-group">
            <div class="input-group"> <span class="input-group-addon"><i class="fa fa-lock"></i></span>
                <input type="password" class="form-control" name="client_password" id="client_password" placeholder="Password" required="required" value="<?php echo $_COOKIE['password']; ?>"/>
            </div>
        </div>
        <br/>
        <a href="client/forgot-password.php" class="pull-right"><i class="icon-question-sign"></i>&nbsp;Forgot Password</a>
        <label>
            <input type="checkbox" name="client_remember" id="client_remember" class="btn btn-mini custom-checkbox active" value="1"
            <?php 
                if(isset($_COOKIE['username']) && isset($_COOKIE['password'])) {
                    echo 'checked="checked"';
                }
                else {
                    echo '';
                }
            ?> >
            &nbsp;&nbsp;&nbsp;Remember Me
        </label>
        <input type="submit" name="customer_submit" id="customer_submit" value="LogIn" class="btn btn-success col-md-offset-5"/>
    </form>
</div>

session_start();    
print_R($_COOKIE);
include('inc/header.php');
//error_reporting(0);
include("agent_database.php");  
if (isset($_POST['customer_submit'])){  

    if ($_SESSION['email'] == $email_input && $_SESSION['password'] == $password_input){

        if(isset($_POST['client_remember']) == 1){

            echo "munesh";
            setcookie('username', $_POST['client_username'], time()+60*60*24*365);
            setcookie('password', $_POST['client_password'], time()+60*60*24*365);

        }else{

            echo "chaudhary";
            setcookie('username', $_POST['client_username'], false);
            setcookie('password', $_POST['client_password'], false);
        }               
        if($result_two > 0){

            $_SESSION['flag'] = true; 
            //echo '<script>location.href="client/dashboard/my-account.php"</script>';          
        }
    }
    $email_input = $_POST['client_username'];
    $client_remember = $_POST['client_remember'];
    $_SESSION['my_email'] = $_POST['client_username'];
    $_SESSION['my_password'] = $_POST['client_password'];
    $password_input = md5($_POST['client_password']); 
    $sql = "SELECT email, password, status FROM customer_regis WHERE email='".$email_input."' && password='".$password_input."' && status = 1 ";
    $result=mysql_query($sql);
    $result_two = mysql_num_rows($result);
    $row = mysql_fetch_assoc($result);
    //echo "<pre>"; print_r($row)."</br>";  
    $_SESSION['email'] = $row['email'];
    $_SESSION['password'] = $row['password'];
    else{

        $danger_msg_client = "please enter a correct email and password!";
    }

}  
</div>
  • 写回答

2条回答 默认 最新

  • douyannuo7733 2015-09-15 10:31
    关注

    Password stored in cookies .. :/ :/ : /?????? Use session..

    评论

报告相同问题?

悬赏问题

  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作