-
Notifications
You must be signed in to change notification settings - Fork 5
/
index_connection.php
60 lines (45 loc) · 1.63 KB
/
index_connection.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
<?php
$host="localhost";
$user="root";
$password="";
$db="attendance";
$con = mysqli_connect($host,$user,$password,$db);
if(isset($_POST['btn-login'])){
$name=$_POST['username'];
$password=$_POST['password'];
$designation1=$_POST['designation'];
$name = mysqli_real_escape_string($con, $name);
$password = mysqli_real_escape_string($con, $password);
$designation1 = mysqli_real_escape_string($con, $designation1);
if(empty($name) || empty($password) || empty($designation1))
{
echo "<script>alert('Please fill the Details..');</script>";
echo "<script> window.location.assign('index.php'); </script>";
}
else
{
$sql="SELECT * FROM `employee_details` WHERE emp_id='$name'AND emp_password='$password'AND emp_designation='$designation1'";
$result=mysqli_query($con,$sql);
$count = mysqli_num_rows($result);
if($count==1)
{
$sql0 = "UPDATE `employee_details` SET emp_check= '0'";
$r0=mysqli_query($con, $sql0);
if($designation1=='employee'){
$sql1 = "UPDATE `employee_details` SET emp_check= '1' WHERE emp_id='$name' ";
$r1=mysqli_query($con, $sql1);
echo "<script> window.location.assign('employee_page_index1.php'); </script>";
}
else if($designation1=='admin'){
$sql2 = "UPDATE `employee_details` SET emp_check= '1' WHERE emp_id='$name'";
$r2=mysqli_query($con, $sql2);
echo "<script> window.location.assign('admin_page_index1.php'); </script>";
}
}
else{
echo "<script>alert('Your credentials are Wrong');</script>";
echo "<script> window.location.assign('index.php'); </script>";
}
}
}
?>