-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert.php
52 lines (45 loc) · 1.67 KB
/
insert.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
<?php header('location: cuslogin.php');
$name = $_POST['name'];
$gender = $_POST['gender'];
$address = $_POST['address'];
$statecode = $_POST['statecode'];
$countrycode = $_POST['countrycode'];
$phonecode = $_POST['phonecode'];
$number = $_POST['number'];
$email = $_POST['email'];
$user = $_POST['user'];
$password = $_POST['password'];
if (!empty($name) || !empty(gender) || !empty($address) || !empty($statecode) || !empty($countrycode) || !empty($phonecode) || !empty($number) || !empty($email) || !empty($user) || !empty($password)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "beauty";
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
if(mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else {
$SELECT = "SELECT email From custoreg Where email = ? Limit 1";
$INSERT = "INSERT Into custoreg (name, gender, address, statecode, countrycode, phonecode, number, email, user, password)values(?, ?, ?, ?, ?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($SELECT);
$stmt->bind_param("s", $email);
$stmt->execute();
$stmt->bind_result($email);
$stmt->store_result();
$rnum = $stmt->num_rows;
if ($rnum==0) {
$stmt->close();
$stmt = $conn->prepare($INSERT);
$stmt->bind_param("sssssiisss", $name, $gender, $address, $statecode, $countrycode, $phonecode, $number, $email, $user, $password);
$stmt->execute();
echo "New record inserted successfully";
} else {
echo "Someone already register using this email";
}
$stmt->close();
$conn->close();
}
} else {
echo "All field are required";
die();
}
?>