-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate.php
More file actions
145 lines (131 loc) · 3.8 KB
/
Copy pathcreate.php
File metadata and controls
145 lines (131 loc) · 3.8 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
session_start();
if(isset($_SESSION['login'])){
header("location:customer.php");
exit;
}?>
<!DOCTYPE html>
<html lang="en">
<head>
<link rel="stylesheet" href="style.css">
<title>Register</title>
</head>
<body>
<header>
<img src="book.png" alt="Logo">
<a href="landing.html" style="color: grey;"><b>BOOK</b></a>
</header>
<br><br><br><br>
<div id="box">
<form method="post">
<div style="font-size: 20px; margin: 10px; padding: 20px; color: white; text-align: center;"><b>CUSTOMER</b></div>
<div style="font-size: 20px; margin: 10px; color: white;">Register</div>
<input id="text" type="text" name="name" placeholder="Name" required><br><br>
<input id="text" type="email" name="email" placeholder="Email" required><br><br>
<input id="text" type="text" name="address" placeholder="Address" required><br><br>
<input id="text" type="password" name="password" placeholder="Password" required><br><br>
<input id="button" type="submit" value="Register"><br><br>
<?php
include("connection.php");
if ($_SERVER['REQUEST_METHOD'] == "POST") {
$name = $_POST['name'];
$email = $_POST['email'];
$address = $_POST['address'];
$password = $_POST['password'];
if (!empty($name) && !empty($email) && !empty($address) && !empty($password)) {
$checkQuery = "SELECT * FROM customers WHERE email = '$email'";
$checkResult = mysqli_query($con, $checkQuery);
if (mysqli_num_rows($checkResult) > 0) {
$message = "Email already exists. Please use a different email.";
$class = "error-message";
} else {
$insertQuery = "INSERT INTO customers (name, email, address, password) VALUES ('$name', '$email', '$address', '$password')";
$insertResult = mysqli_query($con, $insertQuery);
if ($insertResult) {
$message = "Registration successful!";
$class = "success-message";
} else {
$message = "Error in registration. Please try again.";
$class = "error-message";
}
}
} else {
$message = "All fields are required!";
$class = "error-message";
}
}
?>
<?php
if (isset($message)) {
echo "<div class='form-message $class'><strong>$message</strong></div>";
}
?>
</form>
<p style="color: white; text-align: center;">Already have an account? <a href="clogin.php">Login here</a></p>
</div>
</body>
<footer>
<p>© 2023 </p>
</footer>
</html>
<style>
footer {
background-color: transparent;
color: #fff;
text-align: center;
padding: 10px;
position: fixed;
bottom: 0;
width: 100%;
}
body {
background-color: #f0f0f0;
background-image: url('bbook.png');
background-repeat: no-repeat;
background-size: cover;
background-position: center;
}
#box {
background: rgba(0, 0, 0, 0.7);
padding: 20px;
margin: 50px auto;
width: 300px;
height: 520px;
border-radius: 10px;
box-sizing: border-box;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}
.form-message {
text-align: center;
width: 200px;
padding: 10px;
margin: 10px auto;
border-radius: 5px;
}
#button {
background-color: #0d1b2a;
color: #fff;
padding: 10px;
border: none;
border-radius: 5px;
cursor: pointer;
}
#button:hover {
background-color: #005f89;
}
.success-message {
color: white;
background: rgba(0, 255, 0, 0.3); /* Green with low alpha for transparency */
}
.error-message {
color: red;
background: rgba(255, 0, 0, 0.3); /* Red with low alpha for transparency */
}
header {
background-color: black;
color: #fff;
display: flex;
align-items: center;
padding: 10px 20px;
}
</style>