-
Notifications
You must be signed in to change notification settings - Fork 0
/
edit_lesson.php
144 lines (127 loc) · 5.19 KB
/
edit_lesson.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
<?php
include('includes/sidebar.php');
include('includes/connection.php');
?>
<body>
<!-- Update Lesson script ----------->
<?php
if(isset($_REQUEST['update'])){
$course_id = $_REQUEST['c_id'];
$course_name = $_REQUEST['c_name'];
$lesson_id = $_REQUEST['lesson_id'];
$lesson_name = $_REQUEST['l_name'];
$lesson_desc = $_REQUEST['l_desc'];
$lesson_link = $_FILES['lesson_link']['name'];
$temp_link = $_FILES['lesson_link']['tmp_name'];
$position = strpos($lesson_link,".");
$file_extension = substr($lesson_link,$position+1);
$file_extension = strtolower($file_extension);
if(($file_extension!=="mp4")&&($file_extension!="ogg")&& ($file_extension!=="webm")){
$msg = '<span class="bg-danger">Enter Video only</span>';
}else{
$folder = './Videos/'.$lesson_link;
move_uploaded_file($temp_link,$folder);
$sql = "UPDATE lession set lession_id = '$lesson_id',lession_name='$lesson_name',lession_desc='$lesson_desc',course_id = '$course_id',course_name='$course_name',lession_link = '$folder' WHERE lession_id = '$lesson_id'";
if($conn->query($sql) == TRUE){
$msg = '<span class="fs-6" style="color:green;">Lession Successfully updated.</span>';
}else{
$msg = '<span class="fs-6" style="color:green;">Something went wrong.</span>';
}
}
}
?>
<!-- Update Lesson Script End here.. -->
<div class="col-sm-6 mt-2 mx-3 jumbotron main-div">
<?php
if(isset($_REQUEST['view'])){
$edit_key = $_REQUEST['id'];
$sql = "SELECT * FROM lession where lession_id = $edit_key";
$result = $conn->query($sql) or die($conn->error);
$row = $result->fetch_assoc();
}
?>
<form action="#" method="POST" enctype="multipart/form-data" class="c-form">
<div class="form-group">
<label for="cid">Course Id</label>
<input type="text" class="form-control" id="cid" name="c_id"
value="<?php
if(isset($row['course_id'])){
echo $row['course_id'];
}
?>" readonly>
</div>
<div class="form-group mt-3">
<label for="pass">Course Name</label>
<input type="text" class="form-control" id="c_name" name="c_name" value="<?php
if(isset($row['course_name'])){
echo $row['course_name'];
}?>"
required>
</div>
<div class="form-group">
<label for="lid">Lesson ID</label>
<input type="text" class="form-control" id="lid" name="lesson_id"
value="<?php
if(isset($row['lession_id'])){
echo $row['lession_id'];
}
?>" readonly>
</div>
<div class="form-group">
<label for="name">Lesson name</label>
<input type="text" class="form-control" id="name" name="l_name"
value="<?php
if(isset($row['lession_name'])){
echo $row['lession_name'];
}
?>"
required>
</div>
<div class="form-group mt-3">
<label for="l_desc">Lesson Description</label>
<textarea row="10" class="form-control" id="l_desc" name="l_desc" required><?php
if(isset($row['lession_desc'])){
echo $row['lession_desc'];
}
?></textarea>
</div>
<div class="form-group mt-3">
<label for="lesson_link">Lesson Link</label>
<div class="embed-responsive embed-responsive-16by9">
<iframe src="
<?php
if(isset($row['lession_link'])){
echo $row['lession_link'];
}
?>
" frameborder="0" class="embed-responsive-item"></iframe>
</div>
<input type="file" class="form-control-file" name="lesson_link" id="l_video">
</div>
<div class="form-group mt-3">
<?php
if(isset($msg)){
echo "$msg";
}
?>
</div>
<div class="s-button mt-5">
<a href="Lession.php" class="btn bg-secondary">Back</a>
<button type="submit" class="btn btn-danger " id="update" name="update">Update</button>
</div>
</form>
</div>
<script>
var path = window. location. pathname;
var page = path. split("/"). pop();
if(page.localeCompare("Landing.php")){
document.getElementById("dynamicname").innerText = "Edit Lessons"
}
if ( window.history.replaceState ) {
window.history.replaceState( null, null, window.location.href );
}
</script>
</body>
<?php
include('includes/toggle.php');
?>