-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADD.php
128 lines (103 loc) · 3.39 KB
/
ADD.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
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
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST["name"];
$email = $_POST["email"];
$password = $_POST["password"];
$confirm_password = $_POST["confirm_password"];
$room = $_POST["room"];
if ($password !== $confirm_password) {
echo("Passwords do not match!");
}
if (isset($_FILES["profile_picture"]) && $_FILES["profile_picture"]["error"] == UPLOAD_ERR_OK) {
$target_dir = "profile_pictures/";
$target_file = $target_dir . basename($_FILES["profile_picture"]["name"]);
if (move_uploaded_file($_FILES["profile_picture"]["tmp_name"], $target_file)) {
} else {
echo "Failed to upload the profile picture.";
}
}
$user_data = "{$name},{$email},{$password},{$room},{$profile_picture}" . PHP_EOL;
$file = fopen("users.txt", "a");
fwrite($file, $user_data);
fclose($file);
header("Location: login.php");
exit();
}
?>
<!DOCTYPE html>
<html>
<head>
<title>User Registration</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 20px;
}
h2 {
text-align: center;
}
form {
max-width: 400px;
margin: 0 auto;
padding: 20px;
border: 1px solid #ccc;
border-radius: 5px;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"],
input[type="email"],
input[type="password"],
select {
width: 100%;
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 5px;
box-sizing: border-box;
}
input[type="file"] {
margin-top: 5px;
}
input[type="submit"],
input[type="reset"] {
display: inline-block;
padding: 10px 20px;
background-color: #4CAF50;
color: #fff;
border: none;
border-radius: 5px;
cursor: pointer;
}
input[type="submit"]:hover,
input[type="reset"]:hover {
background-color: #45a049;
}
</style>
</head>
<body>
<h2>User ADD</h2>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" enctype="multipart/form-data">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required><br>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required><br>
<label for="password">Password:</label>
<input type="password" id="password" name="password" required><br>
<label for="confirm_password">Confirm Password:</label>
<input type="password" id="confirm_password" name="confirm_password" required><br>
<label for="room">Room No:</label>
<select id="room" name="room" required>
<option value="application1">Application 1</option>
<option value="application2">Application 2</option>
<option value="application2">Cloud</option>
</select><br>
<label for="profile_picture">Profile Picture:</label>
<input type="file" id="profile_picture" name="profile_picture"><br>
<input type="submit" name="submit" value="Save">
<input type="reset" value="Reset">
</form>
</body>
</html>