-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
82 lines (70 loc) · 1.75 KB
/
index.php
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
session_start();
require_once('user.php');
$user = new USER();
if(isset($_POST['btn-signup']))
{
$login = strip_tags($_POST['login']);
$name = strip_tags($_POST['name']);
$upass = strip_tags($_POST['pass']);
if($login=="") {
$error[] = "username !";
}
else if($upass=="") {
$error[] = "password !";
}
else
{
try
{
$stmt = $user->runQuery("SELECT login, name FROM login WHERE login=:login OR name=:name");
$stmt->execute(array(':login'=>$login, ':name'=>$name));
$row=$stmt->fetch(PDO::FETCH_ASSOC);
if($row['login']==$login) {
$error[] = "уже есть!";
}
else if($row['name']==$name) {
$error[] = "уже есть!";
}
else
{
if($user->register($login,$name,$upass)){
echo "ура! зарегистрировалось";
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
}
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Регистрация</title>
<style>
input {
display: block;
}
</style>
</head>
<body>
<div>
<div class="container">
<form method="post">
<h2>Регистрация</h2><hr />
<input type="text" name="login" placeholder="Логин" />
<input type="text" name="name" placeholder="Имя" />
<input type="password" class="form-control" name="pass" placeholder="Пароль" />
<button type="submit" name="btn-signup">
зарегистрироватся
</button>
<label> <a href="login.php">Войти</a></label>
</form>
</div>
</div>
</div>
</body>
</html>