-
Notifications
You must be signed in to change notification settings - Fork 0
/
signup.php
116 lines (107 loc) · 3.54 KB
/
signup.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php session_start();
if (!isset($_POST['submit'])) {
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Sign up</title>
<link rel="stylesheet" href="/static/css/main.css">
<link rel="stylesheet" href="/static/css/signin.css">
</head>
<body>
<div class="login-form">
<form method="post" action="signup.php">
<table>
<tr><td>
First name
<input
type="text"
required
name="first_name"
autofocus
size="15">
</td></tr>
<tr><td>
Last name
<input
type="text"
required
name="last_name"
size="15">
</td></tr>
<tr><td>
Birthday
<input
type="date"
name="date">
</td></tr>
<tr><td>
Email
<input
type="email"
name="email"
placeholder="[email protected]"
size="15">
</td></tr>
<tr><td>
Phone
<input
pattern="[0-9]{10}"
required
maxlength="10"
title="Number must contain +38 plus 10 characters."
type="tel"
name="phone"
size="15">
</td></tr>
<tr><td>
Password
<input
required
type="password"
name="pass"
maxlength="15"
size="15">
</td></tr>
<tr><td colspan="2" align="center">
<input type="submit" name="submit" value="Sign up">
</td></tr>
<tr><td colspan="2" align="center">
<input type="reset" name="reset" value="Reset">
</td></tr>
</table>
</form>
</div>
</body>
</html>
<?php
} else {
$mysql = mysqli_connect("localhost", "root", "") or die ("Неможливо під'єднатись до сервера");
$db = mysqli_select_db($mysql, "dentist") or die ("Даної бази даних не існує");
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$phone = $_POST['phone'];
$pass = $_POST['pass'];
$insert = "first_name='{$first_name}', last_name='{$last_name}', phone='{$phone}', password ='{$pass}'";
if (!empty($_POST['email'])) $insert .= ", email='" . $_POST['email'] . "'";
if (!empty($_POST['date']))
{
$date = date('Y-m-d', strtotime($_POST['date']));
$insert .= ", birthday='" . $date . "'";
}
if ($_POST['submit'] == 'Sign up') $sql = "INSERT INTO users SET {$insert}";
else $sql = "UPDATE users SET {$insert}";
mysqli_query($mysql, $sql);
if (mysqli_affected_rows($mysql) > 0)
{
$_SESSION['phone'] = $phone;
$_SESSION['password'] = $pass;
$_SESSION['first_name'] = $first_name;
header("Location: /templates/home-page.php");
}
mysqli_close($mysql);
}
?>