-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDatabase_test.php
51 lines (44 loc) · 1.28 KB
/
Database_test.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
<?php
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();
}
}
?>