-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathApplicationAnswer.php
More file actions
45 lines (44 loc) · 1.54 KB
/
ApplicationAnswer.php
File metadata and controls
45 lines (44 loc) · 1.54 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
<?php
require "dbConfig.php";
$db = new dbConfig();
$newconnection=mysqli_connect($db->host,$db->username,$db->password,$db->databasename);
mysqli_set_charset($newconnection,"utf8");
if(isset($_POST['Answer']) && isset($_POST['username']) && isset($_POST['start_datum'])&&isset($_POST['slut_datum']))
{
if($_POST['Answer'] == "approve")
{
ApprovingApplication($newconnection,$_POST['username'],$_POST['start_datum'],$_POST['slut_datum'],$_POST['type']);
}
else if ($_POST['Answer'] == "deny")
{
DenyingApplication($newconnection,$_POST['username'],$_POST['start_datum'],$_POST['slut_datum'],$_POST['type']);
}
}
function ApprovingApplication($connection,$uname,$startDate,$endDate,$type)
{
$sql = "INSERT INTO currentactivity (username,type,start_date,end_date) VALUES ('$uname','$type','$startDate','$endDate')";
$result = mysqli_query($connection,$sql);
if($result)
updateValue($connection,$uname);
else
echo "failed to insert a new activity";
}
function DenyingApplication($connection,$uname,$startDate,$endDate,$type)
{
$sql = "DELETE FROM semestertabell where username = '$uname'";
$result = mysqli_query($connection,$sql);
if($result)
echo "Deleted seccessfully";
else
echo "failed to delete";
}
function updateValue($connection, $username)
{
$sql = "UPDATE semestertabell SET value = '1' where username = '$username'";
$result = mysqli_query($connection,$sql);
if($result)
echo "Updated seccessfully";
else
echo "failed to update";
}
?>