";
$randtext = generateRandomString(500);
$randtext = md5($randtext);
$xtm = time()+60*60*24*1;
$sql = "INSERT INTO `temp_token` (`easy_key`, `date_added`, `date_expired`, `ip_add`, `status`, `user_id`) VALUES ('$randtext', '$nowtime', '$xtm', '$ip_add', '1', '0')";
$res = mysqli_query($db, $sql);
if(empty($_POST) == false) {
$fields = array('email2', 'captcha');
foreach($_POST as $key=>$value) {
if(empty($value) && in_array($key, $fields) == true){
$errors = 'All fields are required';
break 1;
}
}
$captcha = $_POST['captcha'];
$email = $_POST['email2'];
$uddt = mysqli_fetch_array(mysqli_query($db, "SELECT COUNT(*), user_id, username, email, email_code, name, active FROM users WHERE email='$email'"));
$tkn = mysqli_fetch_array(mysqli_query($db, "SELECT COUNT(*), easy_key, date_added, ip_add, status, user_id FROM temp_token WHERE easy_key='$captcha'"));
if(empty($errors)) {
if($tkn[0]=='0')
{
$errors = 'Security Key Not Found!';
$res = mysqli_query($db, "INSERT INTO error_log SET tried_username='$email', uid='$uddt[1]', username='$uddt[2]', email='$uddt[3]', action='Resend_Verification', error_msg='Security Key Not Found as $captcha $email', ip_add='$ip_add', time='$nowtime'");
}
if($tkn[4]=='0')
{
$errors = 'Security key Already Used. Please Try Again!';
$res = mysqli_query($db, "INSERT INTO error_log SET tried_username='$email', uid='$uddt[1]', username='$uddt[2]', email='$uddt[3]', action='Resend_Verification', error_msg='security key $captcha already used by you or some one else $email', ip_add='$ip_add', time='$nowtime'");
}
if($uddt[6]=='1')
{
$errors = "Your Account is already active! ";
$res = mysqli_query($db, "INSERT INTO error_log SET tried_username='$email', uid='$uddt[1]', username='$uddt[2]', email='$uddt[3]', action='Resend_Verification', error_msg='Tried to Get Verification Email For previously Active Account', ip_add='$ip_add', time='$nowtime'");
}
if($uddt[0] == '0') {
$errors = 'Sorry, the username \'' . $_POST['email2'] . '\' is not exist.';
$res = mysqli_query($db, "INSERT INTO error_log SET tried_username='$email', uid='$uddt[1]', username='$uddt[2]', email='$uddt[3]', action='Resend_Verification', error_msg='$email does not exist, ip_add='$ip_add', time='$nowtime'");
}
}
}
if(empty($_POST) == false && empty($errors) == true){
$knd = mysqli_fetch_array(mysqli_query($db, "SELECT user_id, username, email, email_code, name FROM users WHERE email='$email'"));
$to = $knd[2];
$title = "$sitename : Verification Email On Request";
$message = "
EMAIL VERIFICATION
Verify Your Email Account
Hello $knd[4], \n\n
Your Login $email \n\n
We dont store your password in plane text format. its stored in encrypted format.\n\n
To activate your account, access the link below: \n\n
$sitelink/activate/$email/$uddt[4]/ \n\n