<form enctype="multipart/form-data" action="register_user.php" method="post">
<table align="center">
<tbody>
<tr>
<td>
Логин:
</td>
<td>
<input name="login" type="text" size="20">
</td>
</tr>
<tr>
<td>
Пароль:
</td>
<td>
<input name="pass" type="text" size="20">
</td>
</tr>
<tr>
<td>
Почта:
</td>
<td>
<input name="email" type="text" size="20">
</td>
</tr>
</tbody>
</table>
<div style='line-height:5px'><br /></div>
<div class='pformstrip' align="center">
<div class='postcolor'>
<input type="submit" value="Отправить">
</div>
</div>
</form>
<?php
require("mysql.inc");
mysql_select_db("l2jdb");
If (!$db)
{
echo "Error: Could not connect to database. Please try again later.";
exit;
}
$login = $_POST["login"];
$pass = $_POST["pass"];
$email = $_POST["email"];
if(isset($login) && isset($pass))
if(strlen($login) < 2)
$return = "Login has to be at least 2 charaters.";
if(strlen($pass) < 6)
$return = "Password has to be at least 6 charaters.";
if($pass==$login)
$return = "Password can't be same as login.";
if(!preg_match("/^[A-Za-z0-9]{2,}$/",$login))
$return = "Invalid login format.";
if(!eregi("^[a-zA-Z0-9]+[_a-zA-Z0-9-]*(\.[_a-z0-9-]+)*@[a-z??????0-9]+(-[a-z??????0-9]+)*(\.[a-z??????0-9-]+)*(\.[a-z]{2,4})$", $email))
$return = "Invalid email format.";
}
if(!isset($return))
{
$result = mysql_query("SELECT login FROM accounts WHERE login='".$login."'");
if(mysql_num_rows($result)==0){
$pass=base64_encode(pack("H*", sha1(utf8_encode($pass))));
$lastactive = time()*1000;
$last_ip = "127.0.0.1";
mysql_query("
INSERT INTO accounts(login, password, lastactive, access_level,lastIP,email)
VALUES('$login', '$pass', '$lastactive', '0', '$last_ip', '$email')"
) or $return = "[red]MySQL ERROR:[/red] ".mysql_error();
$return = "Добро пожаловать, $login. Аккаунт успешно создан.";
} else {
$return = "К сожалению этот логин уже занят.";
}
}
?>