<?php 
ob_start();
session_start();
include('includes/php/dbconnection.php');
//$adminLogin = $_REQUEST['txt_name'];
/*$email = $_REQUEST['txt_email'];

			$selectquery = "SELECT * FROM tbl_admin WHERE admin_username='".$email."'";
			$result = mysql_query($selectquery);
			$row	= mysql_fetch_array($result);
			$loginRowNum = mysql_num_rows($result);
			if($loginRowNum > 0)
			{
			$password = $row['admin_password'];
			
			$message="\t\t".
 			"Your Password is: $password\n";
		
			mail($email, "Password Recovery",$message, "From: www.gsadesign.com");
			header('Location:index.php?msg=success');
			}
			else
			{
				header('Location:password.php?msg=fail');
			}*/







$email_to=$_REQUEST['txt_email'];



// retrieve password from table where e-mail = $email_to(mark@phpeasystep.com)
 $sql="SELECT admin_password FROM tbl_admin WHERE admin_username='$email_to'";
$result=mysql_query($sql);

// if found this e-mail address, row must be 1 row
// keep value in variable name "$count"
$count=mysql_num_rows($result);

// compare if $count =1 row
if($count==1){

$rows=mysql_fetch_array($result);

// keep password in $your_password
$your_password=$rows['admin_password'];

// ---------------- SEND MAIL FORM ----------------

// send e-mail to ...
$to=$email_to;

// Your subject
$subject="Your StMarks admin Password Recovery";

// From

$header = "From: admin@stmarks.com\r\n";
$header .= "MIME-Version: 1.0\r\n";
$header .= "Content-Type: text/html; charset=ISO-8859-1\r\n";



// Your message
//$messages = '<html><body>';

/*$messages= "Your password for login to Stmarks Admin \r\n";
$messages.="Your password is:<b> $your_password \r\n";
$messages.=" \r\n";*/

$messages .= '<table rules="all" style="border-color: #666;border:1px solid #666666;" cellpadding="10">';
$messages .= "<tr style='background: #eee;'><td><strong>User Name:</strong> </td><td>" . strip_tags($email_to)."</td></tr>";
$messages .= "<tr style='background: #eee;'><td><strong>Password</strong> </td><td>" . strip_tags($your_password) . "</td></tr>";
$messages .= "</table>";





//$messages .= '</body></html>';
// send email
$sentmail = mail($to,$subject,$messages,$header);

}

// else if $count not equal 1
else {

$_SESSION['msg']= "Password Recovery Error";
	header("location:password.php");
exit;
}

// if your email succesfully sent
if($sentmail){
$_SESSION['msg']= "You Will soon Recive an E-Mail form St Marks.please Cechk your inbox and spam folder";
header("location:index.php");
exit;
}
else {
$_SESSION['msg']= "Password Recovery Failed, Please Try again later.";
header("location:password.php");
exit;
}




		
?><style type="text/css">
.asdf{border:1px solid #666666;
</style>