<?php
include("db.php");

$id="";
	
if($_POST)
{
  
$checkemail=$db->getVal(" select count(*) from student where email='".$_POST['email']."'");
  
  if($checkemail==""){
	 	 $err=" Email cannot be blank ";
  }elseif($checkemail=="" && $checkemail==0){
 	 $err="Sorry the email which you entered is not registered on our site <br>";
	}else{
		
		$vCode=md5(microtime());
					$db->updateAry("student",array("vcode"=>$vCode),"where idno=".$logdata["userId"]);
					
					$mailAry=array("[FIRST_NAME]"=>$logdata["userUsername"],
									"[EMAIL]"=>$logdata["useremail"],
									"[LINK]"=>URL_ROOT."resetPassword.php?code=".$vCode);
									
					$body="";
					
					mymail($LinksDetails["mail_sender_email"],$email,"Notification ! Sorry ".$logdata["userUsername"]." for  losing your password ",$body,"FORGOT",$mailAry);
					
					$status=array("status"=>"success","msg"=>"Reset Password link has been sent to your email id");	 
	  
	  } 
}
	
if($err!="")
{$smarty->assign("err",$err);}
else{$smarty->assign("err",'404');}

$smarty->assign("profile",$profiledetail);

$smarty->assign("error",$alert_err);

$smarty->display('forgotpassword.html');