This question already has an answer here:
my web application has 3 pages, index.php, oauth.php, and tool.php.
The flow is when the user goes to index.php, they will be redirected to sign in and go to oauth.php and after signing in they are then redirected to tool.php.
I have placed my SQL statements in a if statement checking for $_SESSION['access_token'].Apparently it is empty as when I try to print it,there's an error saying Undefined index : access_token.Does anyone know why it is empty?Please help thank you..
$plus = new Google_Service_Plus($client);
if(isset($_SESSION['access_token']) && $_SESSION['access_token']){
$client->setAccessToken($_SESSION['access_token']);
$me = $plus->people->get('me');
$email = $me['emails'][0]['value'];
$name = $me['displayName'];
$sqlEmail = "SELECT * FROM users WHERE email='".$email."'";
$checkEmail = mysqli_query($conn,$sqlEmail);
if(mysqli_num_rows($checkEmail) >0){
}
else{
$insertStmt = "INSERT INTO users ('email','name','status') VALUES('".$email."','".$name."','user')";
mysqli_query($conn,$insertStmt);
}
}
</div>