-
Notifications
You must be signed in to change notification settings - Fork 1
/
verifyuser.php
61 lines (52 loc) · 1.55 KB
/
verifyuser.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
<?php
//verify and login user from gmail
include("config/config.php");
if(isset($_POST["id"])){
$_SESSION["id"] = $_POST["id"];
$_SESSION["name"] = $_POST["name"];
$_SESSION["email"] = $_POST["email"];
$_SESSION["imgurl"] = $_POST["imgurl"];
$sql = "SELECT usertype FROM user WHERE email='".$_POST["email"]."'";
$res=$res_u=mysqli_query($con,$sql);
$row=$res->fetch_assoc();
$result = $con->query($sql);
if($row["usertype"]=="admin")
{
$sql2 = "UPDATE user SET imgurl='".$_POST["imgurl"]."' WHERE email='".$_POST["email"]."'";
$con->query($sql2);
$usertype="admin";
echo $usertype;//return value to ajax
}
else if($row["usertype"]=="Department")
{
$sql2 = "UPDATE user SET imgurl='".$_POST["imgurl"]."' WHERE email='".$_POST["email"]."'";
$con->query($sql2);
$usertype="Department";
echo $usertype;//return value to ajax
}
else if($row["usertype"]=="Manager")
{
$sql2 = "UPDATE user SET imgurl='".$_POST["imgurl"]."' WHERE email='".$_POST["email"]."'";
$con->query($sql2);
$usertype="Manager";
echo $usertype;//return value to ajax
}
else{
if(!empty($result->fetch_assoc())){
$sql2 = "UPDATE user SET imgurl='".$_POST["imgurl"]."' WHERE email='".$_POST["email"]."'";
$usertype="User";
$con->query($sql2);
echo $usertype;
}else{
$sql2 = "INSERT INTO user (name, email,usertype,imgurl) VALUES ('".$_POST["name"]."', '".$_POST["email"]."', 'User','".$_POST["imgurl"]."')";
$usertype= "Firstuser";
$con->query($sql2);
echo $usertype;
}
}
}
else{
header("Location: index.php");
exit();
}
?>