73 lines
3.5 KiB
PHP
73 lines
3.5 KiB
PHP
|
<?
|
|||
|
session_start();
|
|||
|
$hreject = filter_input(INPUT_COOKIE, GAMEDOMAIN);
|
|||
|
if ($hreject) {
|
|||
|
$error = "Не больше одной регистрации в час!";
|
|||
|
} else {
|
|||
|
|
|||
|
include("config.php");
|
|||
|
$login = filter_input(INPUT_POST, 'login');
|
|||
|
$password = filter_input(INPUT_POST, 'psw');
|
|||
|
$birthday = filter_input(INPUT_POST, 'birthday');
|
|||
|
$email = filter_input(INPUT_POST, 'email', FILTER_VALIDATE_EMAIL);
|
|||
|
$law = filter_input(INPUT_POST, 'law', FILTER_VALIDATE_BOOLEAN);
|
|||
|
$law2 = filter_input(INPUT_POST, 'law2', FILTER_VALIDATE_BOOLEAN);
|
|||
|
$ip = filter_input(INPUT_SERVER, 'REMOTE_ADDR', FILTER_VALIDATE_IP);
|
|||
|
|
|||
|
if ($login && $password && $email && $birthday && $law && $law2) {
|
|||
|
$check = db::c()->query('SELECT 1 FROM `users` WHERE `login` = "?s" OR `email` = "?s"', $login, $email)->getNumRows();
|
|||
|
if ($check > 0) {
|
|||
|
$error = "В системе уже есть такие данные!";
|
|||
|
} else {
|
|||
|
db::c()->query('INSERT INTO `users` (`login`,`pass`,`email`,`borndate`,`ip`,`money`,`sid`)
|
|||
|
VALUES ("?s", "?s", "?s", "?s", "?s", "?s", "?s")', $login, $password, $email, $birthday, $ip, '5', session_id());
|
|||
|
$nid = db::c()->getLastInsertId();
|
|||
|
db::c()->query('INSERT INTO `online` (`id`, `date`, `room`) VALUES (?i, ?i, ?i)', $nid, time(), 1);
|
|||
|
//db::c()->query('UPDATE `users` SET `sid` = "?s" WHERE `id` = ?i', session_id(), $nid);
|
|||
|
setcookie(GAMEDOMAIN, $nid, time() + 3600);
|
|||
|
setcookie("battle", time());
|
|||
|
$_SESSION['uid'] = $nid;
|
|||
|
$_SESSION['sid'] = session_id();
|
|||
|
header('Location: fight.php');
|
|||
|
die();
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//********************************************************************************************
|
|||
|
// Вот этого куска я не понял. Если что-то пойдёт не так, я буду отталкиваться от него.
|
|||
|
//session_start();
|
|||
|
//setcookie("battle", time());
|
|||
|
//$_SESSION['uid'] = $i;
|
|||
|
//mysql_query("UPDATE `users` SET `sid` = '" . session_id() . "' WHERE `id` = {$i} LIMIT 1");
|
|||
|
//
|
|||
|
//$_SESSION['sid'] = session_id();
|
|||
|
//header("Location: fight.php");
|
|||
|
//die();
|
|||
|
//***********************************************************************************************
|
|||
|
?>
|
|||
|
<!DOCTYPE html>
|
|||
|
<html>
|
|||
|
<head>
|
|||
|
<meta charset="utf-8">
|
|||
|
<link href="css/main.css" rel="stylesheet"/>
|
|||
|
<title>Регистрация персонажа</title>
|
|||
|
</head>
|
|||
|
<body>
|
|||
|
<a href="/"> ← на главную</a>
|
|||
|
<?php if (!empty($error)): ?>
|
|||
|
<h1><?php echo $error; ?></h1>
|
|||
|
<?php else: ?>
|
|||
|
<h1>Регистрация</h1>
|
|||
|
<form action="register.php" method="post">
|
|||
|
<input required name="login" placeholder='Имя персонажа'><br>
|
|||
|
<input required name="email" type=email placeholder='Электронная почта'><br>
|
|||
|
<input required name="psw" type=text placeholder='Пароль'><br>
|
|||
|
<label for="bday">Дата рождения:</label><br>
|
|||
|
<input required id="bday" name="birthday" type='date' min=1960-01-01 max=2010-01-01><br>
|
|||
|
<input required id="law" name="law" type=checkbox> <label for="law">Это мой единственный персонаж!</label><br>
|
|||
|
<input required id="law2" name="law2" type=checkbox> <label for="law2">Я согласен на <a href='#'>любые условия</a>, давайте играть!</label><br>
|
|||
|
<input type=submit value=Зарегистрироваться>
|
|||
|
</form>
|
|||
|
<?php endif; ?>
|
|||
|
</body>
|
|||
|
</html>
|