<?


//  cP Account Creator Version 0.4 Beta Build 01
//  Copyright (C) 2004 Brian Freeman
//  All Rights Reserved.
//
//  This script set is distributed as is with absolutely no warranty.
//  Users of this script set agree to use at their own risk.
//  Questions or comments?  Contact webmaster@freemans-web.com
//
//
require("../config.php");
if($lost_pass==1){
if($alt_email=="") {

include("template/header.php");


include("template/lostpw.php");



}
if($alt_email!="") {

require("../config.php");





//$conn  = mysql_connect($dbhost, $dbusername, $dbpass) or die(mysql_error( ));

//mysql_select_db($dbname,$conn) or die(mysql_error( ));



$get_items="SELECT * FROM email_users WHERE username='$username' && email='$alt_email' && first_name='$first_name' && last_name='$last_name'";

$get_items_res=mysql_query($get_items)  or die(mysql_error( ));

if (mysql_num_rows($get_items_res)==1)  {

	while ($items = mysql_fetch_array ($get_items_res)) {

		$cp_username=$items[username];
		$cp_password = $items[raw_pwd];
		$cp_alt_email = $items[email];
		$cp_first_name = $items[first_name];
		$cp_last_name = $items[last_name];

include("../template/add_email.php");

$recipient=$admin_email;
$subject="Account $cp_username lost password request";
$mailheaders="From:  Site Admin <admin@$domain>\n";
mail ($recipient, $subject, $msg_admin_email_lostpw, $mailheaders);

$recipient=$cp_alt_email;
$subject="Your $domain lost password request";
$mailheaders="From:  Site Admin <admin@$domain>\n";
mail ($recipient, $subject, $msg_user_email_lostpw, $mailheaders);
}
echo "Password recovery success.  Password sent to your email.";
}else{

echo "Password recovery not possible.  Some information entered is incorrect or user doesn't exist";
}
}
}else{
  echo "Page access not authorized";
}
?>

