-
Notifications
You must be signed in to change notification settings - Fork 0
/
save_resume.php
125 lines (113 loc) · 3.55 KB
/
save_resume.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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
//handle CORS policy error
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");
if ($_SERVER['REQUEST_METHOD'] == 'OPTIONS') {
exit();
}
include 'connection.php';
$postdata = file_get_contents("php://input");
$param = json_decode($postdata, TRUE);
$user = $param['user'];
$eduList = $param['eduList'];
$expList = $param['expList'];
$skillList = $param['skillList'];
$title = $user['title'];
$name = $user['name'];
$post = $user['post'];
$address = $user['address'];
$contact_no = $user['contact_no'];
$email = $user['email'];
$date_of_birth = $user['date_of_birth'];
$linkedin_profile = $user['linkedin_profile'];
$has_error = 0;
$user_index = -1;
mysqli_autocommit($conn, FALSE);
$query4 = "INSERT INTO resume_user
(`title`
,`post`
,`full_name`
,`address`
,`email`
,`mobile_no`
,`birth_date`
,`linkedin_profile`)
VALUES('$title','$post','$name','$address','$email', '$contact_no'
,'$date_of_birth','$linkedin_profile')";
if ($conn->query($query4) === TRUE) {
$user_index = $conn->insert_id;
} else {
$has_error = 1;
header("HTTP/1.1 500 Internal Server Error");
echo '{"data": "Exception occurred: ' . mysqli_error($conn) . '"}';
mysqli_rollback($conn);
}
for ($x = 0; $x < sizeof($eduList); $x++) {
$course_name = $eduList[$x]['course_name'];
$institute = $eduList[$x]['institute'];
$start_date = $eduList[$x]['start_date'];
$end_date = $eduList[$x]['end_date'];
$query2 = "INSERT INTO education
(`uid`
,`course_name`
,`institute`
,`start_date`
,`end_date`)
VALUES($user_index,'$course_name','$institute','$start_date','$end_date')";
if ($conn->query($query2) === TRUE) {
$conn->insert_id;
} else {
$has_error = 1;
header("HTTP/1.1 500 Internal Server Error");
echo '{"data": "Exception occurred: ' . mysqli_error($conn) . '"}';
mysqli_rollback($conn);
}
}
for ($x = 0; $x < sizeof($expList); $x++) {
$position = $expList[$x]['position'];
$company = $expList[$x]['company'];
$start_date = $expList[$x]['start_date'];
$end_date = $expList[$x]['end_date'];
$description = array_key_exists('description', $expList[$x]) ?
$expList[$x]['description'] : $expList[$x]['description'] = "";
$query3 = "INSERT INTO experience
(`uid`
,`position`
,`company`
,`start_date`
,`description`
,`end_date`)
VALUES($user_index,'$position','$company','$start_date','$description','$end_date')";
if ($conn->query($query3) === TRUE) {
$conn->insert_id;
} else {
$has_error = 1;
header("HTTP/1.1 500 Internal Server Error");
echo '{"data": "Exception occurred: ' . mysqli_error($conn) . '"}';
mysqli_rollback($conn);
}
}
for ($x = 0; $x < sizeof($skillList); $x++) {
$skill = $skillList[$x]['skill'];
$query5 = "INSERT INTO skills
(`uid`
,`skill`)
VALUES($user_index,'$skill')";
if ($conn->query($query5) === TRUE) {
$conn->insert_id;
} else {
$has_error = 1;
header("HTTP/1.1 500 Internal Server Error");
echo '{"data": "Exception occurred: ' . mysqli_error($conn) . '"}';
mysqli_rollback($conn);
}
}
if (!$has_error) {
mysqli_commit($conn);
echo $user_index;
} else {
mysqli_rollback($conn);
}
mysqli_close($conn);
?>