-
Notifications
You must be signed in to change notification settings - Fork 5
/
apply.php
51 lines (39 loc) · 1.24 KB
/
apply.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
<?php
//To Handle Session Variables on This Page
session_start();
if(empty($_SESSION['id_user'])) {
header("Location: index.php");
exit();
}
//Including Database Connection From db.php file to avoid rewriting in all files
require_once("db.php");
//If user Actually clicked apply button
if(isset($_GET)) {
$sql = "SELECT * FROM job_post WHERE id_jobpost='$_GET[id]'";
$result = $conn->query($sql);
if($result->num_rows > 0)
{
$row = $result->fetch_assoc();
$id_company = $row['id_company'];
}
//Check if user has applied to job post or not. If not then add his details to apply_job_post table.
$sql1 = "SELECT * FROM apply_job_post WHERE id_user='$_SESSION[id_user]' AND id_jobpost='$row[id_jobpost]'";
$result1 = $conn->query($sql1);
if($result1->num_rows == 0) {
$sql = "INSERT INTO apply_job_post(id_jobpost, id_company, id_user) VALUES ('$_GET[id]', '$id_company', '$_SESSION[id_user]')";
if($conn->query($sql)===TRUE) {
$_SESSION['jobApplySuccess'] = true;
header("Location: user/index.php");
exit();
} else {
echo "Error " . $sql . "<br>" . $conn->error;
}
$conn->close();
} else {
header("Location: jobs.php");
exit();
}
} else {
header("Location: jobs.php");
exit();
}