-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcustomer-signup1.php
38 lines (33 loc) · 2.06 KB
/
customer-signup1.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
<?php
$error = '';
if (isset($_POST['submit'])) {
$customer_username = $_POST['customer_username'];
$customer_password = $_POST['customer_password'];
$customer_confirm_password = $_POST['customer_confirm_password'];
require 'assets/database/connection.php';
$conn = Connect();
$query = "SELECT customer_username FROM customers WHERE customer_username = '$customer_username'";
$result = $conn->query($query);
if (mysqli_num_rows($result) > 0) { //fetching the contents of the row
$error = "Username is already taken!"; // error prompt
} else {
if ($customer_password != $customer_confirm_password) {
$error = "Password do not matched!";
}else {
$customer_name = $conn->real_escape_string($_POST['customer_name']);
$customer_username = $conn->real_escape_string($_POST['customer_username']);
$customer_email = $conn->real_escape_string($_POST['customer_email']);
$customer_phone = $conn->real_escape_string($_POST['customer_phone']);
$customer_address = $conn->real_escape_string($_POST['customer_address']);
$customer_password = $conn->real_escape_string(md5($_POST['customer_password']));
$query = "INSERT into customers(customer_name,customer_username,customer_email,customer_phone,customer_address,customer_password) VALUES('" . $customer_name . "','" . $customer_username . "','" . $customer_email . "','" . $customer_phone . "','" . $customer_address ."','" . $customer_password ."')";
$success = $conn->query($query);
header("location: customer-registered-success.php");
if (!$success){
die("Couldn't enter data: ".$conn->error);
}
$conn->close();
}
}
}
?>