-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsignup.php
More file actions
161 lines (138 loc) · 4.11 KB
/
signup.php
File metadata and controls
161 lines (138 loc) · 4.11 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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Signup - Maid Service</title>
<link rel="stylesheet" href="css/styles.css">
<style>
body {
font-family: 'Arial', sans-serif;
background: linear-gradient(135deg, #e2e7e7, #1CAD82);
margin: 0;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.container {
display: grid;
grid-template-columns: 1fr 1fr;
gap: 20px;
width: 90%;
max-width: 1200px;
align-items: center;
}
.left-section {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
gap: 20px;
}
.maid_logo {
width: 80%;
max-width: 300px;
}
.form-container {
background: #d6d6d3;
padding: 30px;
border-radius: 15px;
box-shadow: 0 8px 16px rgba(0, 0, 0, 0.3);
width: 100%;
max-width: 400px;
text-align: center;
}
h1 {
margin-bottom: 20px;
font-size: 28px;
color: #444;
}
label {
display: block;
margin: 10px 0 5px;
font-weight: bold;
color: #555;
}
input {
width: 100%;
padding: 12px;
margin-bottom: 20px;
border: 1px solid #ddd;
border-radius: 8px;
background: #f9f9f9;
transition: border-color 0.3s;
}
input:focus {
border-color: #007BFF;
outline: none;
background: #fff;
}
button {
background-color: #007BFF;
color: white;
padding: 12px;
width: 100%;
border: none;
border-radius: 8px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
button:hover {
background-color: #1CAD82;
}
a {
color: #007BFF;
text-decoration: none;
font-weight: bold;
}
a:hover {
text-decoration: underline;
}
</style>
</head>
<body>
<div class="form-container">
<h1>Signup</h1>
<form action="signup.php" method="POST">
<label for="username">Username:</label>
<input type="text" id="username" name="username" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required>
<button type="submit">Signup</button>
</form>
<p>Already have an account? <a href="index.php">Login here</a>.</p>
</div>
</body>
<?php
require 'db.php'; // Include database connection
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['username'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT); // Encrypt password
// Check if email is already registered
$checkEmail = $conn->prepare("SELECT id FROM users WHERE email = ?");
$checkEmail->bind_param("s", $email);
$checkEmail->execute();
$checkEmail->store_result();
if ($checkEmail->num_rows > 0) {
echo "Email is already registered!";
} else {
// Insert new user
$stmt = $conn->prepare("INSERT INTO users (username, email, password) VALUES (?, ?, ?)");
$stmt->bind_param("sss", $name, $email, $password);
if ($stmt->execute()) {
echo "Registration successful! <a href='index.php'>Login here</a>";
} else {
echo "Error: " . $stmt->error;
}
}
$checkEmail->close();
$stmt->close();
}
$conn->close();
?>
</html>