-
Notifications
You must be signed in to change notification settings - Fork 0
/
checker.php
83 lines (60 loc) · 3.14 KB
/
checker.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
<?php
include('session.php');
if($_SERVER["REQUEST_METHOD"] == "POST") {
if(($_POST['roll']=='' && !isset($_POST['sender']) && !isset($_POST['stud'])) || $_POST['message']==''){
echo "<script>window.alert('Please give required inputs')</script>";
die('<a href="login_tchr.php">Go Back</a>');
}
else{
$roll = mysqli_real_escape_string($db,$_POST['roll']);
$message = mysqli_real_escape_string($db,$_POST['message']);
if ($roll != '' )
{
$sql = "SELECT * from login_stu where id=$roll;";
$result = mysqli_query($db,$sql);
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
$count =mysqli_num_rows($result);
if($count == 1) {
if (isset($_POST['stud'])) {
$sql = "SELECT * FROM login_stu where id like '".$_SESSION['class']."%' ;";
$result = mysqli_query($db,$sql);
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
$query = "INSERT INTO notif(id,feedback,date) VALUES ('".$row['id']."', $message, CURRENT_DATE);";
$conclue = mysqli_query($db,$query);
}
if (isset($_POST['sender'])) {
$query = "INSERT INTO feed_principal(id,feedback,date) VALUES ('".$_SESSION['id']."', $message, CURRENT_DATE);";
$conclue = mysqli_query($db,$query);
}
echo "Message Sent Successfully";
die('<a href="login_tchr.php">Go Back</a>');
}
$query = "INSERT INTO notif(id,notifications,date) VALUES ('$roll', '$message', CURRENT_DATE);";
$conclue = mysqli_query($db,$query);
if (isset($_POST['sender'])) {
$query = "INSERT INTO feed_principal(id,feedback,date) VALUES ('".$_SESSION['id']."', $message, CURRENT_DATE);";
$conclue = mysqli_query($db,$query);
}
}
else {
echo "No such student exists!";
die('<a href="login_tchr.php">Go Back</a>');
}
}
if (isset($_POST['sender'])) {
$query = "INSERT INTO feed_principal(id,feedback,date) VALUES ('".$_SESSION['id']."', '$message', CURRENT_DATE);";
$conclue = mysqli_query($db,$query);
}
if (isset($_POST['stud'])) {
$sql = "SELECT * FROM login_stu where id like '".$_SESSION['class']."%' ;";
$result = mysqli_query($db,$sql);
while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){
$query = "INSERT INTO notif(id,feedback,date) VALUES ('".$row['id']."', $message, CURRENT_DATE);";
$conclue = mysqli_query($db,$query);
}
}
echo "Message Sent Successfully";
die('<a href="login_tchr.php">Go Back</a>');
}
}
?>