-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcourse.php
144 lines (134 loc) · 2.86 KB
/
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
<?php
include("header.php");
?>
<script type="application/javascript">
function validation()
{
if(formname.coursename.value=="")
{
alert("Please Enter Course Name...");
formname.coursename.focus();
return false;
}
else if(formname.Description.value=="")
{
alert("Please Enter Description...");
formname.Description.focus();
return false;
}
else if(formname.status.value=="")
{
alert("Please Enter Status...");
formname.status.focus();
return false;
}
else
{
return true;
}
}
</script>
<?php
if($_POST[setid] == $_SESSION[setid])
{
if(isset($_POST[submit]))
{
if(isset($_GET[courseid]))
{
$sql="UPDATE course SET coursename=$_POST[coursename], description=$_POST[dse], status=$_POST[status] WHERE courseid=$_GET[courseid]";
if (!mysqli_query($con,$sql))
{
die(Error: . mysqli_error($con));
}
else
{
$res = "<font color=green>1 record updated</font>";
$resi=1;
}
}
else
{
$sql="INSERT INTO course (coursename, description, status)VALUES ($_POST[coursename],$_POST[dse],$_POST[status])";
if (!mysqli_query($con,$sql))
{
die(Error: . mysqli_error($con));
}
else
{
$res = "<font color=green>1 record added</font>";
$resi=1;
}
}
}
}
$_SESSION[setid] = rand();
$sql="SELECT * FROM course where courseid=$_GET[courseid]";
$qres= mysqli_query($con,$sql);
$rs = mysqli_fetch_array($qres);
?>
<div class="slider_top2">
<h2>Course</h2>
</div>
<div class="clr"></div>
<div class="body_resize">
<div class="body">
<div class="left">
<p>
<form name="formname" method=post action="" onsubmit="return validation()">
<input type="hidden" name="setid" value="<?php echo $_SESSION[setid]; ?>" />
<table class="tftable">
<?php
if($resi==1)
{
echo "<tr> <th colspan=2> $res</th> </tr>";
}
?>
<tr>
<th>Course Name: </th>
<td><input type="text" name="coursename" size=30 value="<?php echo $rs[coursename]; ?>" placeholder="Enter Course Name"/></td>
</tr>
<tr>
<th> Description</th>
<td> <textarea name=dse rows="2" cols="24" placeholder="Enter Description" /><?php echo $rs[description]; ?></textarea></td>
</tr>
<tr>
<th> Status</th>
<td>
<select name="status">
<option>Select</option>
<?php
$arr = array("Enabled","Disabled");
foreach($arr as $val)
{
if($val == $rs[status])
{
echo "<option value=$val selected >$val</option>";
}
else
{
echo "<option value=$val>$val</option>";
}
}
?>
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center" > <input type="submit" name="submit" value="Submit"></td>
</tr>
</table></form>
</p>
<p> </p>
<p> </p>
</div>
<div class="right">
<?php
include("usersidebar.php");
?>
</div>
<div class="clr"></div>
</div>
</div>
<?php
include("footer.php");
?>