-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathregistrationSuccess.php
57 lines (43 loc) · 1.8 KB
/
registrationSuccess.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
<?php
/* Attempt MySQL server connection. Assuming you are running MySQL
server with default setting (user 'root' with no password) */
$link = mysqli_connect("localhost", "root", "", "SpiceItUp");
print_r($_POST);
# print_r($_POST["name"]);
$email = $_POST['email'];
$username = $_POST['username'];
$name = $_POST['name'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zipCode = $_POST['zipcode'];
$password = $_POST['password'];
$pwhash = password_hash($password, PASSWORD_DEFAULT);
// Check connection
if($link === false){
die("ERROR: Could not connect. " . mysqli_connect_error());
}
// Attempt insert query execution
$result = mysqli_query($link, "SELECT Username FROM SpicyCustomers WHERE Username = '$username'");
echo mysqli_num_rows($result);
if(mysqli_num_rows($result) == 0) {
$sql = "INSERT INTO SpicyCustomers (Name, Email, Address, City, State, Zipcode, Username, PasswordHash) VALUES ('$name', '$email', '$address', '$city', '$state', '$zipCode', '$username', '$pwhash')";
if(mysqli_query($link, $sql)){
echo "Records inserted successfully.";
} else{
echo "ERROR: Could not able to execute $sql. " . mysqli_error($link);
}
} /*else{
$sql = "INSERT INTO SpicyCustomers (Name, Email, Address, City, State, Zipcode, Username, PasswordHash) VALUES ('username exists', '$email', '$address', '$city', '$state', '$zipCode', '$username', '$pwhash')";
} */
/*
$sql = "INSERT INTO SpicyCustomers (Name, Email, Address, City, State, Zipcode, Username, PasswordHash) VALUES ('$name', '$email', '$address', '$city', '$state', '$zipCode', '$username', '$pwhash')";
/*
$query = mysql_query("SELECT username FROM SpicyCustomers WHERE username='".$username."'");
if(mysql_num_rows($query) !=0){
echo "Username already exists";
}
*/
// Close connection
mysqli_close($link);
?>