-
Notifications
You must be signed in to change notification settings - Fork 0
/
Databse_test.html
118 lines (103 loc) · 2.32 KB
/
Databse_test.html
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
117
118
<!DOCKTYPE html>
<html>
<title>Php sign in</title>
<body>
<table>
<tr>
<h1>This is my frist database;</h1>
</tr>
<tr>
<td>
<p><b>id:</b></p>
<input type="text" name="id" required>
<br><br>
</td>
</tr>
<tr>
<td>
<p><b>Password:</b></p>
<input type="password" name="password" required>
<br><br>
</td>
</tr>
<tr>
<td>
<p><b>Username:</b></p>
<input type="text" name="username" required>
<br><br>
</td>
</tr>
<tr>
<td>
<p><b>Email</b>:</p>
<input type="email" name="email" required>
<br><br>
</td>
</tr>
<tr>
<td>
<form method="POST">
<!-- This is the button -->
<input type="submit" name="submit" value="Submit">
<?php
//if(array_key_exists('button1', $_POST)) {
// button1();
//}
//else if(array_key_exists('button2', $_POST)) {
// button2();
//}
//function button1() {
// echo "This is Button1 that is selected";
//}
//function button2() {
// echo "This is Button2 that is selected";
//}
if(array_key_exists('Submit', $_POST)) {
doIt();
}
function doIt() {
$id = $_POST['id'];
$password = $_POST['password'];
$username = $_POST['username'];
$email = $_POST['email'];
if(!emtpy($id) ||!emtpy($password) || !emtpy($username) || ($email)){
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "users";
$conn = new sqli($host, $dbUsername, $dbPassword, $dbname);
if (mysqli_connect_errno()){
die('Connect Error('.mysqli_connect_errno().')'.mysqli_connect_error());
} else{
$SELECT = 'SELECT email From users Where email = ? limit 1';
$INSERT = 'INSERT into users($password, $username, $email, $id) values(?, ?, ?, ?)';
$stmt = $conn ->perpare($SELECT);
$stmt -> blind_param("s", $email);
$stmt -> execute();
$stmt -> blind_resutle($email);
$stmt -> store_resutle();
$rnum = $stmt -> num_rows();
if (rnum == 0){
$stmt -> close();
$stmt = $conn -> prepare(INSERT);
$stmt -> blind_param("ssssii", $email, $password, $username, $id);
$stmt -> execute();
echo 'Your informaton is inserted';
} else{
echo 'You cannot make 2 accouts with the same email';
}
$stmt ->close();
$conn ->close();
}
} else{
echo 'Are all of them filled in';
die();
}
}
?>
</form>
</td>
</tr>
</table>
</body>
</html>