Change Password in CodeIgniter

Forms.php (Controller)

<?php
class Forms extends CI_Controller
{
public function __construct()
{
/*call CodeIgniter's default Constructor*/
parent::__construct();
/*load database libray manually*/
$this->load->database();
$this->load->library('session');
/*load Model*/
$this->load->helper('url');
$this->load->model('UserForm');
}

public function update_new_set_password()
{
if($this->input->post('update_new_set_password'))
{
$password_old=$this->input->post('password_old');
$freshpassword=$this->input->post('freshpassword');
$second_time_verify_password=$this->input->post('second_time_verify_password');
$session_id=$this->session->userdata('id');
$que=$this->db->query("select * from client_sign_in where id='$session_id'");
$row=$que->row();
if((!strcmp($password_old, $pass))&& (!strcmp($freshpassword, $second_time_verify_password))){
$this->UserForm->update_new_set_password($session_id,$freshpassword);
echo "Good Luck, Password changed successfully !";
}
else{
echo "sorry, Invalid";
}
}
$this->load->view('update_new_set_password');
}
}
?>

CodeIgniter Model

UserForm.php

<?php
class UserForm extends CI_Model
{
function getUserPassword($session_id)
{
$getUserPassword=$this->db->query("select * from client_sign_in where id='$session_id'");
$res=$getUserPassword->result();
}
function update_new_set_password($session_id,$freshpassword)
{
$update_pass=$this->db->query("UPDATE client_sign_in set pass='$freshpassword' where id='$session_id'");
}
}

CodeIgniter View

update_new_set_password.php

<!DOCTYPE html>
<html>
<head>
<title>Login Form - www.pakainfo.com</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href='//fonts.googleapis.com/css?family=Source+Sans+Pro|Open+Sans+Condensed:300|Raleway' rel='stylesheet' type='text/css'>
</head>
<body>

<div id="main">
<div id="login">
<?php echo @$error; ?>
<h2>Change Password</h2>
<br>
<form method="post" action=''>
<label>Old Password :</label>
<input type="password" name="password_old" id="name" placeholder="Eneter Your Old Pass"/><br /><br />
<label>New Password :</label>
<input type="password" name="freshpassword" id="password" placeholder="Eneter your New Password"/><br/><br />

<label>Confirm Password :</label>
<input type="password" name="second_time_verify_password" id="password" placeholder="Confirm Password"/><br/><br />
<input type="submit" value="login" name="update_new_set_password"/><br />
</form>
</div>
</div>
</body>
</html>

Run the program on your browser with URL:

http://localhost/codeIgniter/index.php/Forms/update_new_set_password

I hope you get an idea about forgot password gmail in codeigniter.


#codeigniter 

Change Password in CodeIgniter
1.00 GEEK