-
Notifications
You must be signed in to change notification settings - Fork 3
/
redirect.php
122 lines (89 loc) · 3.57 KB
/
redirect.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
<script src="//cdn.jsdelivr.net/npm/[email protected]/build/alertify.min.js"></script>
<?php
include('updateScript/createUser.php');
$con=mysqli_connect("localhost","digibd_docket","docket","digibd_docket");
if($con===false)
{
echo '<script type= "text/javascript"> alert ("Database Could not connect")</script>';
}
session_start();
$email=$_SESSION['userData']['email'];
$id = $_SESSION['userData']['id'];
$name = $_SESSION['userData']['first_name'];
$name .= " ";
$name .= $_SESSION['userData']['last_name'];
$picture = $_SESSION['userData']['picture']['url'];
$sql ="SELECT * FROM UserInfo WHERE fb_id = '$id' ";
$query_run = mysqli_query($con,$sql);
if (mysqli_num_rows ($query_run) > 0) {
$sql1 ="SELECT * FROM UserInfo WHERE fb_id = '$id' ";
$query_run = mysqli_query($con,$sql1);
if (mysqli_num_rows($query_run) > 0)
{
$result= mysqli_fetch_array($query_run);
$userID = $result['uniqueId'];
$loggedIn = 1;
$_SESSION['userID'] = $userID;
$_SESSION['loggedIn'] = $loggedIn;
echo "<script> alertify.success('Sign In with Facebook Completed'); </script>";
echo "<script> location.href='UserProfile.php'; </script>";
}
else
{
echo '<script type="text/javascript"> alert ("Login Error")</script>';
}
}
else {
$sql ="SELECT * FROM UserInfo WHERE email = '$email' ";
$query_run = mysqli_query($con,$sql);
if (mysqli_num_rows ($query_run) > 0) {
$query = "UPDATE UserInfo SET fb_id = '$id', verified = 'yes', pictureURL = '$picture' WHERE email = '$email' ";
if(mysqli_query($con,$query)){
$sql1 ="SELECT * FROM UserInfo WHERE fb_id = '$id' ";
$query_run = mysqli_query($con,$sql1);
if (mysqli_num_rows($query_run) > 0)
{
$result= mysqli_fetch_array($query_run);
$userID = $result['uniqueId'];
$loggedIn = 1;
$_SESSION['userID'] = $userID;
$_SESSION['loggedIn'] = $loggedIn;
echo "<script> alertify.success('Sing In with Facebook Completed'); </script>";
echo "<script> location.href='UserProfile.php'; </script>";
}
else
{
echo '<script type="text/javascript"> alert ("Login Error")</script>';
}
}
else{
echo '<script type= "text/javascript"> alert ("Error 1, try again")</script>';
}
}
else {
$query = "INSERT INTO UserInfo (fb_id,userName,email,verified,token,pictureURL) values ('".$id."','".$name."','".$email."','yes','NA','".$picture."')";
if(mysqli_query($con,$query)){
$sql1 ="SELECT * FROM UserInfo WHERE fb_id = '$id' ";
$query_run = mysqli_query($con,$sql1);
if (mysqli_num_rows($query_run) > 0)
{
$result= mysqli_fetch_array($query_run);
$userID = $result['uniqueId'];
$loggedIn = 1;
newUser($userID);
$_SESSION['userID'] = $userID;
$_SESSION['loggedIn'] = $loggedIn;
echo "<script> alertify.success('Sing In with Facebook Completed'); </script>";
echo "<script> location.href='UserProfile.php'; </script>";
}
else
{
echo '<script type="text/javascript"> alert ("Login Error")</script>';
}
}
else{
echo '<script type= "text/javascript"> alert ("Error 2,try again")</script>';
}
}
}
?>