-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsignup_control.php
81 lines (34 loc) · 1.12 KB
/
signup_control.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
<?php
$servername = "localhost";
$username = "stellaa2_costory";
$password = "CSO%YvAwSsTX";
$dbname = "stellaa2_costroy";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$username = $_POST["username"];
$password = $_POST["password"];
$email = $_POST["email"];
$sql = "SELECT name, email FROM users WHERE name = '$username' OR email = '$email' LIMIT 1";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
while($row = $result->fetch_assoc()) {
if( $row["name"] == $username) {$newURL = "signup.php?e=1";}
else if( $row["email"] == $email) {$newURL = "signup.php?e=2";}
}
header('Location: '.$newURL);
} else {
$sql = "INSERT INTO users (name, password, email)
VALUES ('$username', '$password', '$email')";
if ($conn->query($sql) === TRUE) {
$newURL = "signup.php?e=3";
header('Location: '.$newURL);
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
$conn->close();
?>