CodeIgniter Laravel PHP Example Javascript jQuery MORE
Need a Website Or Web Application Or Any Help.Contact Us: +91 9437911966 (Whatsapp) Note: Paid Service
Students Tutorial app relased. Download Now.

How to change password in CodeIgniter framework

In this example we are going to show you How to change password in CodeIgniter framework PHP.

Here we using 3 files for insert data in MySQL:

  • Forms.php Path: codeIgniter\application\controllers\Forms.php
  • Form_model.php Path: codeIgniter\application\models\Form_model.php
  • change_pass.php Path: codeIgniter\application\views\change_pass.php

Forms.php (Controller)

class Forms extends CI_Controller 
	public function __construct()
		/*call CodeIgniter's default Constructor*/
		/*load database libray manually*/
		/*load Model*/
	public function change_pass()
			$que=$this->db->query("select * from user_login where id='$session_id'");
			if((!strcmp($old_pass, $pass))&& (!strcmp($new_pass, $confirm_pass))){
				echo "Password changed successfully !";
					echo "Invalid";

Form_model.php (Model)

class Form_model extends CI_Model 
	function fetch_pass($session_id)
	$fetch_pass=$this->db->query("select * from user_login where id='$session_id'");
	function change_pass($session_id,$new_pass)
	$update_pass=$this->db->query("UPDATE user_login set pass='$new_pass'  where id='$session_id'");

change_pass.php (View)

<!DOCTYPE html>
<title>Login Form</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<link href='|Open+Sans+Condensed:300|Raleway' rel='stylesheet' type='text/css'>

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

		<label>Confirm Password :</label>
		<input type="password" name="confirm_pass" id="password" placeholder="Confirm Password"/><br/><br />
		<input type="submit" value="login" name="change_pass"/><br />

Run the program on your browser with URL:


Here codeIgniter is my folder name. Put your folder name instead of codeIgniter.Rest of things are same.