-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsignup.php
More file actions
99 lines (95 loc) · 2.97 KB
/
Copy pathsignup.php
File metadata and controls
99 lines (95 loc) · 2.97 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
<?php
$host = "localhost";
$user = "root";
$pass = "";
$db = "mini_facebook";
$conn = new mysqli($host, $user, $pass, $db);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] === "POST") {
$fname = $_POST['fname'];
$lname = $_POST['lname'];
$email = $_POST['email'];
$password = password_hash($_POST['password'], PASSWORD_DEFAULT);
$dob = $_POST['dob'];
$gender = $_POST['gender'];
$sql = "INSERT INTO users (first_name, last_name, email, password, dob, gender)
VALUES (?, ?, ?, ?, ?, ?)";
$stmt = $conn->prepare($sql);
$stmt->bind_param("ssssss", $fname, $lname, $email, $password, $dob, $gender);
if ($stmt->execute()) {
echo "<script>alert('Registration successful!'); window.location.href='login.php';</script>";
} else {
echo "Error: " . $conn->error;
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Sign Up | Mini Facebook</title>
<style>
body {
font-family: Arial, sans-serif;
background: #f0f2f5;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
}
.signup-box {
background: white;
padding: 20px 30px;
border-radius: 10px;
box-shadow: 0 0 10px #ccc;
width: 400px;
}
input, select {
width: 100%;
padding: 10px;
margin-top: 10px;
}
.gender {
display: flex;
gap: 10px;
}
.gender label {
margin-right: 10px;
}
button {
width: 100%;
background: #1877f2;
color: white;
border: none;
padding: 12px;
margin-top: 20px;
font-size: 16px;
border-radius: 5px;
}
h2 {
text-align: center;
color: #1877f2;
}
</style>
</head>
<body>
<form method="POST" class="signup-box">
<h2>Create a new account</h2>
<input type="text" name="fname" placeholder="First name" required>
<input type="text" name="lname" placeholder="Last name" required>
<input type="email" name="email" placeholder="Email or mobile number" required>
<input type="password" name="password" placeholder="New password" required>
<p><label>Date of birth:</label></p>
<input type="date" name="dob" required>
<p><label>Gender:</label></p>
<div class="gender">
<label><input type="radio" name="gender" value="Female" required> Female</label>
<label><input type="radio" name="gender" value="Male"> Male</label>
<label><input type="radio" name="gender" value="Custom"> Custom</label>
</div>
<button type="submit">Sign Up</button>
<p>Already have an account ? Click Here to <a href="login.php">login</a></p>
</form>
</body>
</html>