-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpost.php
181 lines (174 loc) · 6.21 KB
/
post.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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
<?php
error_reporting(0);
require_once "config.php";
require_once "loginfo.php";
if (!isset($_SESSION['loggedin'])) {
header('Location: ln.php');
exit;
}
$cname = $location = $position = $Jdesc = $skills = $CTC = "";
$cname_err = $location_err = $position_err = $Jdesc_err = $skills_err = $CTC_err = "";
if ($_SERVER['REQUEST_METHOD'] == "POST"){
// Check for company name
if(empty(trim($_POST['cname']))){
$cname_err = "Company name cannot be blank";
echo "<p class='echocss'>Company name cannot be blank.</p>";
}
else{
$cname = $_POST['cname'];
// Check for location
if(empty(trim($_POST['location']))){
$location_err = "location cannot be blank";
echo "<p class='echocss'>location cannot be blank.</p>";
}
else{
$location = $_POST['location'];
// Check for position
if(empty(trim($_POST['position']))){
$position_err = "position cannot be blank";
echo "<p class='echocss'>Position cannot be blank.</p>";
}
else{
$position = $_POST['position'];
// Check for Job description
if(empty(trim($_POST['Jdesc']))){
$Jdesc_err = "Job description cannot be blank";
echo "<p class='echocss'>Job description cannot be blank.</p>";
}
else{
$Jdesc = $_POST['Jdesc'];
// Check for skills
if(empty(trim($_POST['skills']))){
$skills_err = "skills cannot be blank";
echo "<p class='echocss'>skills cannot be blank.</p>";
}
else{
$skills = $_POST['skills'];
// Check for CTC
if(empty(trim($_POST['CTC']))){
$CTC_err = "CTC cannot be blank";
echo "<p class='echocss'>CTC cannot be blank.</p>";
}
else{
$CTC = $_POST['CTC'];
}
}
}
}
}
}
// If there were no errors, go ahead and insert into the database
if(empty($cname_err) && empty($location_err) && empty($position_err) && empty($Jdesc_err) && empty($skills_err) && empty($CTC_err))
{
$sql = "INSERT INTO jobs (cname, location, position, Jdesc, skills, CTC) VALUES (?, ?, ?, ?, ?, ?)";
$stmt = mysqli_prepare($conn, $sql);
if ($stmt)
{
mysqli_stmt_bind_param($stmt, "ssssss", $param_cname, $param_location, $param_position, $param_Jdesc, $param_skills, $param_CTC);
// Set these parameters
$param_cname = $cname;
$param_location = $location;
$param_position = $position;
$param_Jdesc = $Jdesc;
$param_skills = $skills;
$param_CTC = $CTC;
// Try to execute the query
if (mysqli_stmt_execute($stmt))
{
header("location: successful.php");
}
else{
header("location: failed.php");
echo "Error: Failed to post the job $sql.".mysqli_error($conn);
}
}
mysqli_stmt_close($stmt);
}
}
?>
<title>Post Job</title>
<link rel="shortcut icon" type="image/x-icon" href="img/NLJ.png">
<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3" crossorigin="anonymous">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css" integrity="sha512-Fo3rlrZj/k7ujTnHg4CGR2D7kSs0v4LLanw2qksYuRlEzO+tcaEPQogQ0KaoGN26/zrn20ImR1DfuLWnOo7aBA==" crossorigin="anonymous" referrerpolicy="no-referrer" />
<style>
body{
background:url('img/post.jpg') no-repeat;
background-size: cover;
padding: 0;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
color: rgb(48, 46, 46);
}
.echocss{
margin-left: 40em;
margin-top: -20px;
position: absolute;
color: red;
font-weight: bold;
}
.card-body{
background-color: light gray;
margin-top: 25px;
width: 1001px;
margin-left: 259px;
height: 96%;
}
/* On screens that are less than 700px wide, make the sidebar into a topbar */
@media screen and (max-width: 1156px) {
.echocss{
margin-left: 20em;
margin-top: -20px;
position: absolute;
color: red;
font-weight: bold;
}
body{
background:url('img/post.jpg');
width: 100%;
background-size: cover;
padding: 0;
margin: 0;
font-family: Arial, Helvetica, sans-serif;
color: rgb(48, 46, 46);
}
.card-body{
background-color: #E5E8E8;
width: 70%;
margin-left:15%;
margin-top: 10%;
height: 700px;
}
}
</style>
<div>
<div class="card card-body">
<form action="" method="POST">
<div class="mb-3">
<label for="company name" class="form-label">Company Name</label>
<input type="text" class="form-control" id="" name="cname" placeholder="Enter company name">
</div>
<div class="mb-3">
<label for="location" class="form-label">Location</label>
<input type="text" class="form-control" id="" name="location" placeholder="Enter company location">
</div>
<div class="mb-3">
<label for="exampleInputPosition" class="form-label">Position</label>
<input type="text" class="form-control" id="exampleInputPosition" name="position" placeholder="Enter position">
</div>
<div class="mb-3">
<label for="JobDesc" class="form-label">Job Description</label>
<textarea name="Jdesc" class="form-control" id="JobDesc" placeholder="Describe the position" style="height: 150px;"></textarea>
</div>
<div class="mb-3">
<label for="Skills" class="form-label">Skills Required</label>
<input type="text" class="form-control" id="skills" name="skills" placeholder="Enter skills">
</div>
<div class="mb-3">
<label for="CTC" class="form-label">CTC</label>
<input type="text" class="form-control" id="CTC" name="CTC" placeholder="Enter CTC">
</div>
<button type="submit" class="btn btn-primary" name="submit">Submit</button>
</form>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-ka7Sk0Gln4gmtz2MlQnikT1wXgYsOg+OMhuP+IlRH9sENBO0LRn5q+8nbTov4+1p" crossorigin="anonymous"></script>