Öncelikle Vermiş Olduğunuz Cevap İçin Teşekkür Ederim Hocam Ben Buna Ek Olarak Üyenin Farklı Bilgilerinide Almak İstiyorum Fakat Bunları Eklediğimde Hata Veriyor Yardımcı Olursanız Sevinirim Hocam.
Aldığım Hata
Warning: Missing argument 8 for User::checkUser(), called in /home/grantbet/public_html/face/login-facebook.php on line 37 and defined in /home/grantbet/public_html/face/config/functions.php on line 7
You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`name` = '' `First_Name` = '' `Last_name` = '' and `oauth_provider` = 'facebook'' at line 1
Php Kodu
functions.php
<?php
require 'dbconfig.php';
class User {
function checkUser($uid, $oauth_provider, $username,$email,$First_name,$Last_name,$twitter_otoken,$twitter_otoken_secret)
{
$query = mysql_query("SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'") or die(mysql_error());
$result = mysql_fetch_array($query);
if (!empty($result)) {
# User is already present
} else {
#user not present. Insert a new Record
$query = mysql_query("SELECT * FROM `users` WHERE `oauth_uid` = '".$uid."' `name` = '".$name."' `First_Name` = '".$First_name."' `Last_name` = '".$Last_name."' and `oauth_provider` = '".$oauth_provider."'") or die(mysql_error());
$query = mysql_query("SELECT * FROM `users` WHERE oauth_uid = '$uid' and oauth_provider = '$oauth_provider'");
$result = mysql_fetch_array($query);
return $result;
}
return $result;
}
}
?>Home.php
<?php
//Always place this code at the top of the Page
session_start();
if (!isset($_SESSION['id'])) {
// Redirection to login page twitter or facebook
header("location: index.php");
}
echo '<h1>Hoşgeldiniz</h1>';
echo 'id : ' . $_SESSION['id'];
echo '<br/>Kullanıcı Adınız : ' . $_SESSION['email'];
echo '<br/>Ad- Soyad : ' . $_SESSION['username'];
echo '<br/>Parola : ' . $_SESSION['parola'];
echo '<br/>You are login with : ' . $_SESSION['oauth_provider'];
echo '<br/>Logout from <a href="logout.php?logout">' . $_SESSION['oauth_provider'] . '</a>';
?>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />facebook_login.php
<?php
require 'facebook/facebook.php';
require 'config/fbconfig.php';
require 'config/functions.php';
$facebook = new Facebook(array(
'appId' => APP_ID,
'secret' => APP_SECRET,
));
$user = $facebook->getUser();
if ($user) {
try {
// Proceed knowing you have a logged in user who's authenticated.
$user_profile = $facebook->api('/me');
} catch (FacebookApiException $e) {
error_log($e);
$user = null;
}
if (!empty($user_profile )) {
# User info ok? Let's print it (Here we will be adding the login and registering routines)
$username = $user_profile['name'];
$uid = $user_profile['id'];
$email = $user_profile['email'];
$first_name = $user_profile['First_name'];
$last_name = $user_profile['Last_name'];
$user = new User();
$userdata = $user->checkUser($uid, 'facebook', $username,$email,$First_name.$Last_name,$twitter_otoken,$twitter_otoken_secret);
if(!empty($userdata)){
session_start();
$_SESSION['id'] = $userdata['id'];
$_SESSION['oauth_id'] = $uid;
$_SESSION['username'] = $userdata['username'];
$_SESSION['email'] = $email;
$_SESSION['oauth_provider'] = $userdata['oauth_provider'];
$_SESSION['First_name'] = $userdata['First_name'];
$_SESSION['Last_name'] = $userdata['Last_name'];
header("Location: home.php");
}
} else {
# For testing purposes, if there was an error, let's kill the script
die("There was an error.");
}
} else {
# There's no active session, let's generate one
$login_url = $facebook->getLoginUrl(array( 'scope' => 'email'));
header("Location: " . $login_url);
}
?>