Location: PHPKode > projects > l2jweb > set_new_passwd.php
<?
function crypt_p($pass)
{
    return base64_encode(pack('H*', sha1(utf8_encode($pass))));
}
$smarty->assign('SEND_TO', $_SERVER['REQUEST_URI'].'&done=true');
$content = '';
$errr_msg = '';
$sql = "SELECT `Username`, `password` FROM `users` WHERE `email`='".mysql_escape_string($_POST['email'])."' AND `validation_code`='".$_GET['code']."'";
$id_sql = $db->query($sql);
if ($db->num_rows($id_sql)!=0){
	$user = $db->fetch_array($id_sql);	
	if (@$_GET['done']==true)
		{
			if ($_POST['passwd']!=$_POST['passwd2'])
				$errr_msg .= 'Passwords don\'t match<br>';
			else {
				$sql = "CALL change_passwd('".$user[0]."', '".$user[1]."', '".crypt_p($_POST['passwd'])."')";
				$sql_id = $db->query($sql);
				if ($db->affected_rows($sql_id)==0)
					$errr_msg .= 'There was an error. Please contact you server admin.';}
		}
	else  $errr_msg .= 'Please fill both fields!';
	$smarty->assign('CHANGEPASSWDMSG', $errr_msg);
	if (strlen($errr_msg)!=0) $content = $smarty->fetch('new_passwd.tpl');
		else $content = 'Password was changed!';
}
?>
Return current item: l2jweb