-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapply.php
43 lines (32 loc) · 1.05 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
<?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)) {
//Check if user has applied to job post or not. If not then add his details to apply_job_post table.
$sql1 = "SELECT * FROM contacts WHERE id_user='$_SESSION[id_user]' AND id_friend='$_GET[id]'";
$result1 = $conn->query($sql1);
if($result1->num_rows == 0) {
$sql = "INSERT INTO contacts(id_friend, id_user) VALUES ('$_GET[id]', '$_SESSION[id_user]')";
if($conn->query($sql)===TRUE) {
$_SESSION['jobApplySuccess'] = true;
header("Location: contacts.php");
exit();
} else {
echo "Error " . $sql . "<br>" . $conn->error;
}
$conn->close();
} else {
header("Location: view-profile.php?id=$_GET[id].php");
exit();
}
} else {
header("Location: jobs.php");
exit();
}