View file iblog/admin/controller/reset_password.php

File size: 1.13Kb
<?php
	session_start();
	include "../../lib/config.php";
	include "../../lib/functions_class.php";
	
	function sendmail($center_email,$email,$password){
		$to = $email;
		
		// subject
		$subject = "Password-Reset Successful";

		// compose message
		$body = "<center>
					<h2>Password Reset Successful</h2><br><br>
					
					<h3>Your Password: ".$password."</h3><br><br>
					
					<h4>Thank you</h4>
				</center>";
				
		$message = $body;

		// To send HTML mail, the Content-type header must be set
		$headers = "MIME-Version: 1.0\r\n";
		$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
		$headers .= "From: ".$center_email."\r\n";
		$headers .= "Reply-To: ".$center_email."\r\n";
		
		mail($to, $subject, $message, $headers);
	}
	//End Email Sending
	
	$email = $_POST['email'];
	$center_email = $DB->get_settingdata('center_email');
	$checkemail=$DB->findemail($email);
	$newpass = rand();
	$password=md5($newpass);
	
	if($email == ''){
		echo "Please Enter your email";
	}
	else if($checkemail == 0){
		echo "2";
	}
	else{

		$DB->recoverpassword($email,$password);
		sendmail($center_email,$email,$newpass);
		
		echo "1";
	}
	
?>