-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprocessTutorForm.php
More file actions
91 lines (62 loc) · 2.1 KB
/
Copy pathprocessTutorForm.php
File metadata and controls
91 lines (62 loc) · 2.1 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
89
90
91
<head>
<title>Confirmation Page</title>
</head>
<body>
<?php
$servername = "lists.slsd.org";
$username = "qiand";
$password = "1755440";
$dbName = "tutoringSignup";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbName);
$id =(int) $_POST["ID"];
$name = $_POST["name"];
$email = $_POST["email"];
$isTutor = $_POST["person"]=="tutor"?"Tutor":"Request";
$tmpTimes = $_POST["time"];
$tmpSubjects = $_POST["subject"];
$times = array();
$subjects = array();
$count = 0;
for($i = 0; $i < count($tmpTimes); $i++) {
echo $tmpTimes[$i]. "<br>";
if($tmpTimes[$i] == "true") {
echo "ASDGASDGSADGASD <br>";
$times[$count] = =$i;
}
}
$count = 0;
for($j = 0; $j < count($tmpSubjects); $j++) {
echo count($tmpSubjects) . "<br>";
if($tmpSubjects[$j] == "true") {
echo "pihjopihjfj <br>";
$subjects[$count] = $j;
}
}
// Check connection
if ($conn->connect_error)
die("Connection failed: " . $conn->connect_error);
$conn->query("DELETE FROM ".($isTutor)."s"." WHERE ID_number=".$id);
$conn->query("DELETE FROM ".($isTutor)."Times"." WHERE ID_number=".$id);
$conn->query("DELETE FROM ".($isTutor)."Subjects"." WHERE ID_number=".$id);
$conn->query("INSERT INTO ".($isTutor)."s"." (ID_number, Name, Email, laptopName) VALUES ('".$id."', '" . $name . "', '".$email."','laptop')");
echo "INSERT INTO ".($isTutor)."s"." (ID_number, Name, Email, laptopName) VALUES ('".$id."','".$name."','".$email."','laptop')";
for($i = 0; $i < count($times); $i++) {
$conn->query("INSERT INTO ".($isTutor)."Times"." (ID_number, Time) VALUES ('".$id."','".$times[$i]."')");
}
for($i = 0; $i < count($subjects); $i++) {
$conn->query("INSERT INTO ".($isTutor)."Times"." (ID_number, Subject) VALUES ('".$id."','".$subjects[$i]."');");
}
echo("Succesful sign up");
/*
$result = $conn->query("SELECT * FROM tutors");
if ($result->num_rows > 0)
while($row = $result->fetch_assoc())
echo "id: " . $row["id"]. " - Name: " . $row["firstname"]. " " . $row["lastname"]. "<br>";
else
echo "0 results";
$conn->close();
*/
?>
</body>
</html>