<?PHP
#	This takes the email entered on display page 3 and sends a verification code to that address.
$email=tapRequest("email");
if (is_null($email))
{
	$newby=3;
	$errmsgs.=addError("You did not enter an email for us to verify.");
}
else
{
	if (_FORM_checkEmail($email))
	{
		$valcode=crypt($_SERVER["REMOTE_ADDR"].time());
		$_SESSION["valcode"]=$valcode;
		$uri="https://".$_SERVER["HTTP_HOST"].$_SERVER["SCRIPT_NAME"]."?vc=$valcode";
		$plain=INTERNAL_NAME." has sent you this validation code\n$valcode\nYou can complete the validation process by returning to the web page and pasting it in the box provided there.";
		$html="<p>We have assigned to you a validation code of $valcode.  You can either copy it into the box on the screen in your browser or click on <a href=$uri>this link</a>.  If you click on this link, you will almost certainly open a new tab or window in your browser.";
		if (email_HTML($email,EMAIL_EMAILER,"Your validation code",DEFAULT_BOUNDARY_CODE,$html,$plain))
		{
			$msgs.=addMessage("We have sent a validation code to you at $email.");
			loggywoggy("Verification email sent to $email with $valcode.");
		}
		else
		{
			$errmsgs.=addError("We were unable to send you an email.  We should take care of this soon.  Please come back later.");
			admin_nnotify("Unable to email","We failed in an attempt to send a verification email to $email.");
			$newby=3;
		}
	}
	else
	{
		$newby=3;
		$errmsgs.=addError("Your email address, $email, is not in the valid form of user@domain.superdomain.");
	}
}
?>