-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_course.php
246 lines (192 loc) · 5.6 KB
/
edit_course.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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
<?php
include("db_connection.php");
session_start();
if(isset($_GET['id'])) {
$course_id = $_GET['id'];
$query = "SELECT * FROM course WHERE id = '$course_id'";
$result = mysqli_query($con, $query);
if($result && mysqli_num_rows($result) > 0) {
$course = mysqli_fetch_assoc($result);
} else {
// Redirect or display an error message if course not found
}
} else {
// Redirect or display an error message if course ID is not provided
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Edit Course</title>
<style>
/* CSS styles for the form */
/* Base styles */
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
div.header {
position: fixed;
top: 0;
left: 0;
right: 0;
background: #CADCFC;
z-index: 1000;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.5rem 1rem; /* Adjust header padding for smaller screens */
}
div.header h1 {
color: #000000;
font-size: 1rem; /* Adjust header font size for smaller screens */
text-transform: uppercase;
}
div.header button {
font-size: 0.8rem; /* Adjust button font size for smaller screens */
padding: 0.5rem 1rem;
border-radius: 5px;
}
h2 {
text-align: center;
margin-top: 110px;
margin-bottom: 10px; /* Add a bottom margin to create space */
font-size: 1.5rem;
}
form {
width: 90%; /* Set form width to 80% for responsiveness */
max-width: 350px; /* Limit form width on larger screens */
margin: 20px auto; /* Center the form */
padding: 20px;
background-color: #fff;
box-shadow: 0 0 20px rgba(0, 0, 0, 0.1);
}
label {
display: block;
margin-bottom: 10px;
}
input[type="text"],
input[type="file"] {
width: 100%;
padding: 10px;
margin-bottom: 20px;
box-sizing: border-box;
}
img {
max-width: 70%;
height: auto;
margin-bottom: 20px;
}
input[type="submit"] {
padding: 10px 20px;
background-color: #007bff;
color: #fff;
border: none;
cursor: pointer;
border-radius: 5px;
}
input[type="submit"]:hover {
background-color: #0056b3;
}
.btn {
background-color: #f7f7f7;
color: #000000;
padding: 10px 20px;
border: none;
border-radius: 5px;
text-decoration: none;
font-size: 0.7rem;
}
.btn:hover {
background-color: #0056b3;
}
/* Media queries for responsiveness */
@media (max-width: 768px) {
div.header {
padding: 0.5rem; /* Adjust header padding for smaller screens */
}
div.header h1 {
font-size: 1.2rem; /* Reduce header font size for smaller screens */
}
div.header button {
font-size: 0.7rem; /* Reduce button font size for smaller screens */
padding: 0.4rem 0.8rem;
}
form {
width: 30%; /* Adjust form width for smaller screens */
}
input[type="text"],
input[type="file"] {
font-size: 0.9rem; /* Reduce input font size for smaller screens */
}
img {
max-width: 70%; /* Ensure images are responsive */
}
}
@media (max-width: 480px) {
div.header {
padding: 0.3rem; /* Further adjust header padding for smallest screens */
}
div.header h1 {
font-size: 1rem; /* Further reduce header font size for smallest screens */
}
div.header button {
font-size: 0.6rem; /* Further reduce button font size for smallest screens */
padding: 0.3rem 0.6rem;
}
form {
width: 100%; /* Adjust form width to full width for smallest screens */
}
input[type="text"],
input[type="file"] {
font-size: 0.8rem; /* Further reduce input font size for smallest screens */
padding: 8px;
}
input[type="submit"] {
font-size: 0.8rem; /* Reduce submit button font size for smallest screens */
padding: 8px 16px; /* Adjust submit button padding for smallest screens */
}
.btn {
font-size: 0.6rem; /* Further reduce button font size for smallest screens */
padding: 8px 16px; /* Adjust button padding for smallest screens */
}
}
</style>
<script>
function validateForm() {
var courseName = document.getElementById("course_name").value;
// Regular expression to match only alphabetical characters
var regex = /^[a-zA-Z ]+$/;
if (!regex.test(courseName)) {
alert("Course name should contain only alphabetical characters.");
return false;
}
return true;
}
</script>
</head>
<body>
<!-- Your existing HTML code -->
<div class="header">
<a href="admin_pannel.php" class="btn">Go Back</a>
<h1><?php echo $_SESSION['AdminLoginId']?></h1>
<!-- <button name="Logout">LOG OUT</button> -->
</div>
<h2>Edit Course</h2>
<form action="update_course.php" method="post" enctype="multipart/form-data" onsubmit="return validateForm()">
<input type="hidden" name="course_id" value="<?php echo $course_id; ?>">
<label for="course_name">Course Name:</label>
<input type="text" id="course_name" name="course_name" value="<?php echo $course['course_name']; ?>" required>
<label for="price">Price:</label>
<input type="text" id="price" name="price" value="<?php echo $course['price']; ?>" required>
<label for="image">Image:</label>
<img src="<?php echo $course['image']; ?>" alt="Course Image">
<input type="file" id="image" name="image">
<input type="submit" value="Update">
</form>
</body>
</html>