<?php

include('init.php');
include('libs/functions.php');

if (isset($_POST['email'])) {
$email = scrub_sql(scrub_white_list($_POST['email'], 'USER'), 150);
$sql = "SELECT user_id, username FROM tb_user WHERE email='$email';";
$rs = $db->Execute($sql);
$record_count = $rs->RecordCount();
if ($record_count == 1) {
$user_id = $rs->fields('user_id');
$user = $rs->fields('user');
}

}




print_header();



?>



<script>
function check_form() {
var errs=0;
if (!document.getElementById('uorp1').checked && !document.getElementById('uorp2').checked) {alert('Please select either username or password'); errs=1;}
else if (document.forms.forgot.fname.value == '') {alert('Please enter your first name'); errs=1;}
else if (document.forms.forgot.lname.value == '') {alert('Please enter your last name'); errs=1;}
else if (checkMail()) {alert('Please enter a valid email address'); errs=1;}

return (errs==0);
}

function checkMail()
{
	var x = document.forms.forgot.email.value;
	var filter  = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
	if (filter.test(x)) return false;
	else return true;
}


</script>



<div id="login" style="border: thin solid; margin-left: auto; margin-right: auto; width: 500px; padding: 25px 25px 25px">













<TABLE cellpadding="3" cellspacing="1" border="0">
<tr>
<td>
<H1 align="CENTER">Lookup Username or Password</H1>
</td>
</tr>
<tr>
<td>
<HR>
<p>
Please complete the information below to retrieve your lost/forgotten Veterans Re-Entry Search Service username or password. The system will send you an email containing your username or a temporary password.</p>
<HR>
</td>
</tr>
<tr>
<td>
<form name="forgot" action="retrieve_login.php" method="post" onSubmit="return check_form();">

<TABLE>
<TR><TD>
<input type="radio" name="uorp" id="uorp1" value="1"> <label for="uorp1">I forgot my username</label>  <input type="radio" name="uorp" id="uorp2" value="2"> <label for="uorp2">I forgot my password</label>
</td></tr>
<tr>
<td>
<BR>

<div id="formdisplay">
<TABLE>
<tr>
<td width="200"><label for="fname">First Name</label></td>
<td width="400"><input type="text" name="fname" id="fname" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="200"><label for="lname">Last Name</label></td>
<td width="400"><input type="text" name="lname" id="lname" size="20" maxlength="20"></td>
</tr>
<tr>
<td width="200"><label for="email">Email</label></td>
<td width="400"><input type="text" name="email" id="email" size="40" maxlength="120"></td>
</tr>

</TABLE>
<BR>
<CENTER>
<INPUT TYPE="SUBMIT" VALUE="Retrieve Login"> <INPUT TYPE="Button" VALUE="Cancel" onClick="window.location='/';">

</CENTER>
</div>

</td>
</tr>
</TABLE>
</form>

</td>
</tr>
</TABLE>





</div>








<?php

print_footer();


?>