How to change password in CodeIgniter?

Today, We want to share with you change password in codeigniter.In this post we will show you how to send password reset link in codeigniter?, hear for check old password and updating a new password using codeigniter we will give you demo and example for implement.In this post, we will learn about forgot password in codeigniter with an example.

How to Make Forgot 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:

Also Read This πŸ‘‰   Vue.js Binding Fundamentals Using V-Bind Directive

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

I hope you get an idea about forgot password gmail in codeigniter.
I would like to have feedback on my infinityknow.com blog.
Your valuable feedback, question, or comments about this article are always welcome.
If you enjoyed and liked this post, don’t forget to share.

Also Read This πŸ‘‰   PHP Whatsapp Rest API Send and Recieve WhatsApp Message