-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplication.php
More file actions
90 lines (88 loc) · 2.82 KB
/
application.php
File metadata and controls
90 lines (88 loc) · 2.82 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
<?php
// session_start();
require_once 'core/init.php';
// if(isset($_SESSION['logged_in'])){
// echo "Bad Request";
// die();
// }
?>
<?php
// Check if user is logged in
if(!isset($_SESSION['email'])){
echo "<script>window.open('login.php','_self')</script>";
}
?>
<?php
// Select the user based on logged in email
$email = $_SESSION['email'];
$sqlcus = "SELECT * FROM customers WHERE email = '$email'";
$result = $db->query($sqlcus);
while ($row_pro = mysqli_fetch_array($result)) {
$cus_id = $row_pro['id'];
$cus_name = $row_pro['fullname'];
$cus_email = $row_pro['email'];
$cus_address1 = $row_pro['address1'];
$cus_city = $row_pro['city'];
$cus_phone = $row_pro['phone'];
}
?>
<?php
// Fetch the internship selected/applied
if(isset($_GET['apply'])){
$id = sanitize((int)$_GET['apply']);
$sqlint = "SELECT * FROM internships WHERE deleted=0 AND id = '$id'";
$internships = $db->query($sqlint);
while ($internship = mysqli_fetch_assoc($internships)) {
$int_name = $internship['category'];
$company_name = $internship['nameOfCompany'];
}
$sql = "SELECT * FROM applications WHERE int_id = '$id'";
$applications = $db->query($sql);
while ($application = mysqli_fetch_assoc($applications)) {
$cus_app_id = $application['cus_id'];
$int_app_id = $application['int_id'];
}
$insertSql = "INSERT INTO applications (`cus_id`,`int_id`,`applied`) VALUES ('$cus_id','$id', 1)";
$insert = $db->query($insertSql);
if($insert){
?>
<script type="text/javascript">
alert('Successfully applied for the internship!');
</script>
<?php
header("location:./internship.php?internship=$id");
}else{
echo $db->error;
?>
<!-- <script type="text/javascript">
alert('Sorry your internship application could not be added!');
</script> -->
<?php
}
}
else{
echo "Data is missing, please select the internship";
exit();
}
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<title>Assignment</title>
<!-- Font Awesome -->
<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.8.2/css/all.css">
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Material Design Bootstrap -->
<link href="css/mdb.min.css" rel="stylesheet">
<!-- Your emptom styles (optional) -->
<link href="css/style.css" rel="stylesheet">
</head>
<body>
<!-- Message for succesful application -->
<h2 class="text-center text-success p-3">Dear <?=$cus_name;?>, You have successfully applied for <b><?=$int_name; ?></b> internship by <b><i><?=$company_name;?></i></b></h2>
<a href="index.php" class="btn btn-default">Go Back</a>
</body>
</html>