PHP MVC CodeIgniter Laravel Core PHP
Need a Website Or Web Application Or Any Help.Contact Us: +91 9437911966 (Whatsapp) Note: Paid Service

Forgot password in MVC with example

Here is the Controller file hello.php which inside controllers folder



class Hello extends Controller {

	function __construct() {
function forgot_password(){ if(isset($_POST['forgot'])) { $email=$this->input->post('email'); $que=$this->db->query("select email,pass from user_data where email='$email'"); $row=$que->row(); $user_email=$row->email; if((!strcmp($email, $user_email))){ $pass=$row->pass; /*Mail Code*/ $to = $user_email; $subject = "Password"; $txt = "Your password is $pass ."; $headers = "From:" . "\r\n" . "CC:"; mail($to,$subject,$txt,$headers); } } $this->view->render('hello/forgot_pass'); } } ?>

Here is the view file forgot_passl.php which inside views folder contains the form.


<!DOCTYPE html>
<form method="post" action="forgot_password"> 
	<input type="email" name="email"><br> 
	<input type="submit" name="forgot">
Path to run : localhost/project_folder_name/view_folder_name/view_filename
Example: localhost/mvc/hello/send_mail