HTML :
<form id="login-form" method="post" action="login">
<div class="faimage"><i class="fa fa-envelope"></i> </div>
<input id="login_username" class="form-control" type="text" name="email" placeholder="Email Address" value="<?php echo isset($_COOKIE['username']) ? $_COOKIE['username'] : '' ?>" required>
<input id="login_password" class="form-control" type="password" name="password" placeholder="Password" value="<?php echo isset($_COOKIE['password']) ? $_COOKIE['password'] : '' ?>" required>
</div>
<div class="checkbox">
<label> <input type="checkbox" name="remember_me" value="1"> Remember Me </label>
</div>
<div>
<input type="submit" class="btn formbtn" name="submitlogin" value="Login">
</div>
</form>
PHP :
function login()
{
$this->load->helper('cookie');
$remember = $this->input->post('remember_me');
if( $remember=='1' && $remember!=='' ){
// setcookie( name, value, expire, path, domain, secure, httponly );
setcookie("username", $this->input->post('email'), time() + 3600);
setcookie("password", $this->input->post('password'), time() + 3600);
// $this->input->set_cookie('username', $this->input->post('email'), '604800');
// and add one week to it's expiration
}
}
__________________________
// $result = array();
// foreach($_POST as $key => $row)
// {
// $var[$key] = $row;
// array_push($result,$var);
// }
<form id="login-form" method="post" action="login">
<div class="faimage"><i class="fa fa-envelope"></i> </div>
<input id="login_username" class="form-control" type="text" name="email" placeholder="Email Address" value="<?php echo isset($_COOKIE['username']) ? $_COOKIE['username'] : '' ?>" required>
<input id="login_password" class="form-control" type="password" name="password" placeholder="Password" value="<?php echo isset($_COOKIE['password']) ? $_COOKIE['password'] : '' ?>" required>
</div>
<div class="checkbox">
<label> <input type="checkbox" name="remember_me" value="1"> Remember Me </label>
</div>
<div>
<input type="submit" class="btn formbtn" name="submitlogin" value="Login">
</div>
</form>
PHP :
function login()
{
$this->load->helper('cookie');
$remember = $this->input->post('remember_me');
if( $remember=='1' && $remember!=='' ){
// setcookie( name, value, expire, path, domain, secure, httponly );
setcookie("username", $this->input->post('email'), time() + 3600);
setcookie("password", $this->input->post('password'), time() + 3600);
// $this->input->set_cookie('username', $this->input->post('email'), '604800');
// and add one week to it's expiration
}
}
__________________________
// $result = array();
// foreach($_POST as $key => $row)
// {
// $var[$key] = $row;
// array_push($result,$var);
// }
Comments
Post a Comment