-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_company_details.php
243 lines (223 loc) · 7.59 KB
/
index_company_details.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
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
<?php
session_start();
if(!isset($_SESSION['user']))
{
header("Location: vit.php");
}
if($_SESSION['user']=='student_int' )
{
header("Location: index_student_intern.php");
}
if($_SESSION['user']=='student_place' )
{
header("Location: index_student_placement.php");
}
if($_SESSION['user']=='admin')
{
header("Location: index_admin.php");
}
?>
<?php
$company_id="";
$company_name="";
$company_type="";
$website="";
$address2="";
$coming_date="";
$c_type="";
$branch1="";
$min_cgpa="";
$max_backlogs="";
$max_salary="";
$max_stipend="";
$job_profile="";
$place_of_posting="";
$disp="";
$errors = array();
$positives=array();
$db = mysqli_connect('localhost', 'root', '', 'placement');
//session_start();
if (isset($_POST['reg_company_details']))
{
// receive all input values from the form
$company_name = mysqli_real_escape_string($db, $_POST['company_name']);
$c_type = mysqli_real_escape_string($db, $_POST['c_type']);
$branch1 = mysqli_real_escape_string($db, $_POST['branch1']);
$min_cgpa = mysqli_real_escape_string($db, $_POST['min_cgpa']);
$max_backlogs = mysqli_real_escape_string($db, $_POST['max_backlogs']);
$max_salary = mysqli_real_escape_string($db, $_POST['max_salary']);
$max_stipend = mysqli_real_escape_string($db, $_POST['max_stipend']);
$job_profile = mysqli_real_escape_string($db, $_POST['job_profile']);
$place_of_posting = mysqli_real_escape_string($db, $_POST['place_of_posting']);
// form validation: ensure that the form is correctly filled ...
// by adding (array_push()) corresponding error unto $errors array
if($_SESSION['company_name']==$company_name)
{
if (empty($company_name))
{
array_push($errors, "Company name is required");
}
if (empty($c_type))
{
array_push($errors, "company type is required");
}
if (empty($branch1))
{
array_push($errors, "Branch is required");
}
if (empty($min_cgpa))
{
array_push($errors, "Min CGPA is required");
}
/* if (empty($max_backlogs))
{
array_push($errors, "Max Backlogs is required");
}*/
if (empty($job_profile))
{
array_push($errors, "Job_Profile is required");
}
if (empty($place_of_posting))
{
array_push($errors, "Place_of_Posting is required");
}
if (empty($max_stipend) &&(($c_type=='internship') or ($c_type=='Internship') or($c_type=='intern') or ($c_type=='Intern')))
{
array_push($errors, "Stipend is required");
}
if (empty($max_salary) &&(($c_type=='placement') or ($c_type=='Placement')))
{
array_push($errors, "Salary is required");
}
if (!(empty($max_salary)) &&($c_type=='Internship'))
{
array_push($errors, "Company is of type internship,No salary");
}
if (!(empty($max_stipend)) && ($c_type=='Placement') )
{
array_push($errors, "Company is of type Placement,No Stipend");
}
// first check the database to make sure
// a user does not already exist with the same username and/or email
$user_check_query = "SELECT * FROM companybranch WHERE COMPANY_NAME='$company_name' AND C_TYPE='$c_type' AND BRANCH='$branch1' LIMIT 1";
$result = mysqli_query($db, $user_check_query);
//The mysqli_fetch_assoc() function fetches a result row as an associative array.
$user = mysqli_fetch_assoc($result);
if ($user)
{ // if user exists
if ($user['COMPANY_NAME'] === $company_name)
{
array_push($errors, "Company name already exists");
}
if ($user['C_TYPE'] === $c_type)
{
array_push($errors, "Company Type already exists");
}
if ($user['BRANCH'] === $branch1)
{
array_push($errors, "Branch already exists");
}
}
// Finally, register user if there are no errors in the form
if (count($errors) == 0)
{
$query = "INSERT INTO companybranch (COMPANY_NAME,C_TYPE,BRANCH,MIN_CGPA,MAX_BACKLOGS,MAX_SALARY,MAX_STIPEND,JOB_PROFILE,PLACE_OF_POSTING)
VALUES('$company_name', '$c_type', '$branch1', '$min_cgpa', '$max_backlogs', '$max_salary', '$max_stipend', '$job_profile', '$place_of_posting')";
mysqli_query($db, $query);
$_SESSION['company_name'] = $company_name;
$_SESSION['success'] = "Company Successfully updated details";
$disp="Company Successfully Enter details";
// echo "company Successfully enter the detail";
//if we want to empty all the entered details then again initialize all the$variable_name to "";
array_push($positives, "Company Successfully updated details");
//header('location: index_company.php');
}
}
else
{
array_push($errors, "Company name is wrong");
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Information from Company</title>
<link rel="stylesheet" type="text/css" href="1.css">
<link rel="shortcut icon" type="image/png" href="vit.png">
<link rel="stylesheet" type="text/css" href="stl.css">
</head>
<body >
<div class="list-unstyled3" >
<ul>
<li><a href="vit.php"><img src="vit.png" alt="VIT Pune" class="logo2" height="40" align="left"/></a></li>
<li style="float:right"><a href="logout.php" title="<?php echo $_SESSION['company_name']; ?> ">Log Out</a></li>
<div class="para">
<p> Training & Placement,VIT Pune</p>
</div>
</ul>
</div>
<div class="header">
<h2>Details from Company</h2>
</div>
<form method="post" action="index_company_details.php">
<?php include('wrong.php'); ?>
<?php include('positive.php'); ?>
<div class="input-group">
<label>Company name</label>
<input type="text" name="company_name" value="<?php echo $_SESSION['company_name']; ?>" readonly>
</div>
<div class="input-group">
<label>Company Type</label>
<!--<input type="text" name="c_type" value="<?php echo $c_type ?>"> -->
<select name="c_type" >
<option value="Internship">Internship</option>
<option value="Placement">Placement</option>
</select>
</div>
<div class="input-group">
<label>Branch</label>
<!-- <input type="text" name="branch1" value="<?php echo $branch1 ?>"> -->
<select name="branch1" >
<option value="CSE">Computer Science and Engineering</option>
<option value="ECE">Electronics and Comm. Engineering</option>
<option value="EE">Electrical Engineering</option>
<option value="CE">Civil Engineering</option>
<option value="ME">Mechanical Engineering</option>
<option value="CHE">Chemical Engineering</option>
<option value="MME">Metallurgical and Materials Engineering</option>
</select>
</div>
<div class="input-group">
<label>Minimum Cgpa</label>
<input type="text" name="min_cgpa" value="<?php echo $min_cgpa ?>">
</div>
<div class="input-group">
<label>Max Backlogs</label>
<input type="text" name="max_backlogs" value="<?php echo $max_backlogs ?>">
</div>
<div class="input-group">
<label>Max Salary</label>
<input type="text" name="max_salary" value="<?php echo $max_salary ?>">
</div>
<div class="input-group">
<label>Max Stipend</label>
<input type="text" name="max_stipend" value="<?php echo $max_stipend ?>">
</div>
<div class="input-group">
<label>Job Profile</label>
<input type="text" name="job_profile" value="<?php echo $job_profile ?>">
</div>
<div class="input-group">
<label>Place of Posting</label>
<input type="text" name="place_of_posting" value="<?php echo $place_of_posting ?>">
</div>
<div class="input-group">
<button type="submit" class="btn" name="reg_company_details">Enter Details</button>
</div>
<p>
Added all details <a href="index_company.php">Go Back</a>
</p>
</form>
</body>
</html>