-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseeker_controller.php
More file actions
172 lines (158 loc) · 5.21 KB
/
Copy pathseeker_controller.php
File metadata and controls
172 lines (158 loc) · 5.21 KB
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
<?php
session_start();
require_once("includes/db_connect.php");
if (isset($_GET['action'])&& $_GET['action']!='') {
$action=$_GET['action'];
} else {
'';
}
switch ($action) {
case"add":
add_data();
break;
case"login":
seeker_login();
break;
case"edit":
edit_data();
break;
case"delete":
delete_data();
break;
}
function add_data()
{
global $connection;
if (isset($_POST['signup'])) {
$name="";
$Phone="";
$email="";
$password="";
$valid=true;
if ($_POST['name']=="") {
$_SESSION['name']= "fname field is required";
$valid=false;
header("Location:seeker_signup.php");
} elseif (preg_match("/^[a-zA-Z-']*$/", $_POST['name'])) {
$name=$_POST['name'];
// echo $name;
} else {
$_SESSION['name']="fname must contains only letters";
$valid=false;
header("Location:seeker_signup.php");
}
if ($_POST['phone']=="") {
$_SESSION['phone']="phone field is required";
$valid=false;
header("Location:seeker_signup.php");
} elseif (strlen($_POST['phone'])==11) {
$phone=$_POST['phone'];
$sql="SELECT phone FROM job_seekers WHERE phone='$phone'";
$res=mysqli_query($connection, $sql);
$row1=mysqli_num_rows($res);
if ($row1>0) {
$_SESSION['phone']= "This $phone is already exists";
$valid=false;
}
} else {
$_SESSION['phone']="phone must contains 11 integers";
$valid=false;
header("Location:seeker_signup.php");
}
if ($_POST['email']=="") {
$_SESSION['email']= "email field is required";
$valid=false;
} elseif (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$email=$_POST['email'];
$sql="SELECT email FROM job_seekers WHERE email='$email'";
$data=mysqli_query($connection, $sql);
$row=mysqli_num_rows($data);
if ($row>0) {
$_SESSION['email']= "This $email is already exists";
}
$email=$_POST['email'];
$sql="SELECT Email FROM employees WHERE Email='$email'";
$data=mysqli_query($connection, $sql);
$row=mysqli_num_rows($data);
if ($row>0) {
$_SESSION['email']= "you already signup as employeer with this Email $email choose different";
$valid=false;
header("Location:seeker_signup.php");
}
} else {
$_SESSION['email']="Enter Valid Email";
$valid=false;
}
if ($_POST['password']=="") {
$_SESSION['password']="password field is required";
$valid=false;
} elseif (strlen($_POST['password'])>4) {
$password=$_POST['password'];
// echo $password;
} else {
$_SESSION['password']= "password must be 5 digits";
$valid=false;
}
if ($valid) {
$query1="INSERT INTO `job_seekers`( `name`,`phone`,`email`,`password`) VALUES('$name','$phone','$email','$password')";
global $connection;
$result= mysqli_query($connection, $query1);
if ($result) {
$_SESSION['successmsg']="signup successfully";
header("location:seeker_login.php");
} else {
$_SESSION['errormsg']="data not insert";
header("Location:seeker_signup.php");
}
}
}
}
function seeker_login()
{
global $connection;
if (isset($_POST['login'])) {
$email="";
$password="";
$valid=true;
if ($_POST['email']=="") {
$_SESSION['emaill']= "email field is required";
$valid=false;
} elseif (filter_var($_POST['email'], FILTER_VALIDATE_EMAIL)) {
$email=$_POST['email'];
} else {
$_SESSION['emaill']="Enter Valid Email";
$valid=false;
}
if ($_POST['password']=="") {
$_SESSION['password']="password field is required";
$valid=false;
} elseif (strlen($_POST['password'])>4) {
$password=$_POST['password'];
// echo $password;
} else {
$_SESSION['password']= "password must be 5 digits";
$valid=false;
}
if ($valid) {
$sql="SELECT s_id,name FROM job_seekers WHERE email='$email'&& password='$password'";
$data=mysqli_query($connection, $sql);
$row=mysqli_num_rows($data);
if ($row>0) {
$arr=mysqli_fetch_assoc($data);
$_SESSION['seeker_id']=$arr['s_id'];
$_SESSION['seeker_name']=$arr['name'];
header("Location:index.php");
} else {
$_SESSION['errormsg']="password or email wrong";
header("Location:seeker_login.php");
}
}
}
}
function edit_data()
{
echo "edit data function";
}function delete_data()
{
echo "delete data function";
}