-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathst_search.php
More file actions
88 lines (69 loc) · 2.17 KB
/
Copy pathst_search.php
File metadata and controls
88 lines (69 loc) · 2.17 KB
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
<!DOCTYPE html>
<html>
<head>
<title>New Search</title>
</head>
<body>
<form action="includes/cancel.php">
<button type="submit" name="submit">Cancel search</button>
</form>
<?php
function redirect($url)
{
//supposed to redirect user
$string = '<script type="text/javascript">';
$string .= 'window.location = "' . $url . '"';
$string .= '</script>';
echo $string;
}
session_start();
include_once "dbh.inc.php";
$_SESSION['iter'] = $_SESSION['iter'] + 1;
$_SESSION['flag'] = 0;
echo "Waiting for tutor request...";
if ($_SESSION['iter'] < 2){
//if first time through code, inserts tutor info into db
$contact = $_SESSION['u_email'];
$sql = "SELECT rating, num_rate FROM users WHERE user_email = '$contact'";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
$rating = $row['rating']
$topic = $_POST['topic'];
$tutor = $_SESSION['u_first'] . " " . $_SESSION['u_last'];
$sql = "INSERT INTO running_t (tu_name, tu_email, tu_topic, rating) VALUES ('$tutor', '$contact', '$topic', $rating);";
mysqli_query($conn, $sql);
} else {
//if it is not the first time, that means the user clicked no
$sql = "INSERT INTO response (stu_email, answer) VALUES ($_SESSION['pemail'], 'no')";
mysqli_query($conn, $sql);
}
//flags are used so the code nows if db updates are needed once cancelled
$_SESSION['flag2'] = false
do{
$sql = "SELECT * FROM fullfil WHERE tu_email='$contact' LIMIT 1";
$result = mysqli_query($conn, $sql);
$row = mysqli_fetch_assoc($result);
sleep(5);
} while (mysqli_num_rows($result)<1);
$_SESSION['flag2'] = true;
$_SESSION['pname'] = $row["st_name"];
$des = $row['descript'];
$_SESSION['pemail'] = $row['st_email'];
echo $_SESSION['pname'] . "needs help with this problem: " . $des;
$contact = $_SESSION['u_email'];
$sql = "DELETE FROM fullfil WHERE tu_email='$contact'";
mysqli_query($conn, $sql);
if ($row['rej'] > 3){
//redirects if student has been denied multiple times
$_SESSION['flag'] = 1;
redirect(yes.php);
}
?>
<form action ="includes/yes.php">
<button type="submit" name="submit">Accept</button>
</form>
<form action ="includes/st_search.php">
<button type="submit" name="submit">Reject</button>
</form>
</body>
</html>