Skip to content
  • Homepage
  • HTML
  • CSS
  • Symfony
  • PHP
  • How to
  • Contact
  • Donate

Teach Developer

Articles, Guides & Tips

How to change password in the CodeIgniter framework

Home  »  Codeigniter • How to   »   How to change password in the CodeIgniter framework
Posted on September 17, 2022September 17, 2022
800

How to send forgot password in CodeIgniter framework PHP.

Here we using 2 files to insert data in MySQL:

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

Forms.php (Controller)

<?php 
class Forms extends CI_Controller 
{
   public function __construct()
   {
        parent::__construct();
        $this->load->database();
        $this->load->library('session');
	$this->load->helper('url');
	$this->load->model('Hello_model');
   }	
   
   public function forgot_pass()
   {
	if($this->input->post('forgot_pass')) 
        {
	   $email=$this->input->post('email');
	   $que=$this->db->query("select pass,email from user_login where      email='$email'");
	   $row=$que->row();
	   $user_email=$row->email;
	   if((!strcmp($email, $user_email)))
           {
		$pass=$row->pass;
		$to = $user_email;
		$subject = "Password";
		$txt = "Your password is $pass .";
		$headers = "From: password@example.com" . "\r\n" .
		   "CC: ifany@example.com";

		mail($to,$subject,$txt,$headers);
	   } else {
	       $data['error']="Invalid Email ID !";
	   }	
	}
      $this->load->view('forgot_pass',@$data);	
  }	            
}
?>

forgot_pass.php (View)

<!DOCTYPE html>
<html>
  <head>
    <title>Login Form</title>
      <link rel="stylesheet" type="text/css" href="css/style.css">
  </head>
  <body>
    <div id="main">
      <div id="login">
        <?php echo @$error; ?>
          <h2>Forgot Password</h2> <br />
          <form method="post" action=''>
	    <label>Email ID :</label>
	    <input type="password" name="email" id="name" placeholder="Email ID"/><br /><br />
	    <input type="submit" value="login" name="forgot_pass"/><br />
          </form>
        </div>
      </div>
</body>
</html>
 

Run the program on your browser with URL:

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

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

Codeigniter, How to Tags:PHP

Post navigation

Previous Post: How to Use useLocation Hook in React Router DOM V6
Next Post: How to Recover Deleted WhatsApp Messages

Related Posts

  • How to Delete Unused Database Tables in WordPress
  • How to make the scrollbar visible in mobile browsers with CSS?
  • How to Enable Debug Mode in Laravel
  • How to Send Email from Localhost in PHP
  • How to use events listeners and Event Subscriber in Symfony
  • How to install Git on Linux

Categories

  • Codeigniter (3)
  • CSS (11)
  • eCommerce (1)
  • Framework (1)
  • Git (3)
  • How to (43)
  • HTML (5)
  • JavaScript (15)
  • Jquery (7)
  • Laravel (1)
  • Linux (4)
  • Magento-2 (1)
  • Node js (4)
  • Others (2)
  • PHP (11)
  • React (13)
  • Server (1)
  • SSH (3)
  • Symfony (6)
  • Tips (16)
  • Top Tutorials (10)
  • Ubuntu (3)
  • Vue (1)
  • Wordpress (7)

Latest Posts

  • What is SSH in Linux?
  • How to Delete Files in Ubuntu Command Line
  • How to Deploy a React application on a cPanel
  • How to use events listeners and Event Subscriber in Symfony
  • How to Convert PHP CSV to JSON

WEEKLY TAGS

AJAX (1) Codeigniter (1) Javascript (11) JQuery (1) PHP (16) Programming (1) React (3) Symfony (1)

Random Post

How to use the Local Storage in Javascript
How to style an HTML radio button to look like a checkbox with CSS?
Dealing with deprecations
How to Object Destructuring in ES6
How to use setTimeout and setInterval methods in JavaScript

Quick Navigation

  • About
  • Contact
  • Privacy Policy

© Teach Developer 2021. All rights reserved