-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstu2.php
76 lines (74 loc) · 2.17 KB
/
stu2.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
<?php
session_start();
$db=mysqli_connect('localhost','root','','feedbacktrial') or die("Unable to connect mysql server.");
$sno=$_SESSION['s_no'];
if(isset($_SESSION['redir'])){
$id=$_SESSION['id'];
//rate1
if(isset($_POST['rate1']))
$r1=$_POST['rate1'];
else{
echo "<script> window.location='question.php';
alert('not checked button 1') </script>";
}
//rate2
if(isset($_POST['rate2']))
$r2=$_POST['rate2'];
else{
echo "<script> window.location='question.php';
alert('not checked button 2') </script>";
}
//rate3
if(isset($_POST['rate3']))
$r3=$_POST['rate3'];
else{
echo "<script> window.location='question.php';
alert('not checked button 3') </script>";
}
//rate4
if(isset($_POST['rate4']))
$r4=$_POST['rate4'];
else{
echo "<script> window.location='question.php';
alert('not checked button 4') </script>";
}
//rate5
if(isset($_POST['rate5']))
$r5=$_POST['rate5'];
else{
echo "<script> window.location='question.php';
alert('not checked button 5') </script>";
}
if($r1 and $r2 and $r3 and $r4 and $r5){
$s="INSERT into feed values ('$sno','$id','$r1','$r2','$r3','$r4','$r5')";
$r=mysqli_query($db,$s);
$rat=(float) ($r1+$r2+$r3+$r4+$r5)/5;
$s1="SELECT * from fac_feed where username='$id' ";
$rs1=mysqli_query($db,$s1);
$n=1;
if(!mysqli_num_rows($rs1)){
$s2="INSERT into fac_feed values ('$id','$rat','$n')";
$rs2=mysqli_query($db,$s2);
}
else{
$res=mysqli_fetch_assoc($rs1);
$prev=$res['rating'];
$n=$res['no_std'];
$n++;
$fin=(float) ($prev+$rat)/2;
$s3="UPDATE fac_feed set rating='$fin', no_std='$n' where username='$id' ";
$rs3=mysqli_query($db,$s3);
}
echo "<script> window.location='stu1.php';
alert('FEEDBACK SAVED SUCCESSFULLY ') </script>";
}
mysqli_close($db);
}
?>
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>