php echo div class hide Регистрация div switch _GET act default echo f

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
echo '<div class = "hide">Регистрация</div>';
switch ($_GET['act']){
default:
echo '<form action = "?act=ok" method = "POST">';
echo '<div class = "block">';
echo 'Ник: <br />
<input type = "text" name = "nick"> <br />
Имя: <br />
<input type = "text" name = "name"> <br />
Пароль: <br />
<input type = "text" name = "password"> <br />
<input type = "submit" name = "go">';
echo '</div></form>';
break;
case 'ok':
if (isset($_POST['go'])){
$error = array();
$nick = $_POST["nick"];
$name = $_POST["name"];
$pass = $_POST["password"];
if(!isset($nick)) $errors[] = "Ошибка";
if(!isset($pass)) $errors[] = "Ошибка";
if(strlen($pass)<6 || strlen($pass)>32) $errors[] = "Ошибка";
if(preg_match("/\=|\+|\{|\}|\(|\)|\^|\%|\\$|#|@|!|&|\~|'|\"|:|;|`|,|\.|\?|<|>/",$nick)) $errors[] = "Ошибка";
if(empty($errors)){
//db::getInstance()-> query("INSERT INTO `users` SET `id` = 'NULL', `nick` = '".$nick."', `password` = '".md5($pass)."', `name` = '".$name."'");
echo "INSERT INTO `users` SET `id` = 'NULL', `nick` = '".$nick."', `password` = '".md5($pass)."', `name` = '".$name."'";
echo '<div class = "block">
Регистрация прошла успешно.<br />
Ник: '.$nick.'<br />
Пароль: '.$pass.' <br />
<a href = "/">Войти</a>
</div>';
}else{
echo "<div class=\"error\">\n".implode("<br>\n", $errors)."</div>\n<br><a href=\"".$_SERVER["HTTP_REFERER"]."\"><img src=\"img/back.gif\">Назад</a>\n";
}
}
break;
}