开发者

facebook, how to handle users that already have an account?

I've been using a facebook script to allow users to log into my website using theyr username and password.

what happens is that the script allows users to create accounts on the website but if the user clicks again on the facebook button, the facebook widget doesn't know that the user has an account already and tries to create another one.

here is the iframe code:

    <iframe src="http://www.facebook.com/plugins/registration.php?
         client_id=1389887264&
     redirect_uri=http://www.xxx.com/user_add.php&
         fields=<?php echo urlencode($fields);?>"
    width="100%"
    height="350">
</iframe>

in the user_add.php i am grabbing the values returned from the facebook login dialog:

  $phone = $response['regi开发者_StackOverflow中文版stration']['phone'];
  $cell = $response['registration']['phone'];
  $zip = $response['registration']['zipcode'];
  ....

and i am passing them in a function that creates accounts in my website.

But what if the user exists already? What the facebook code will be? and i need the user to enter the username and password from facebook and make a relationship with the username and pass already existent on my website and log them in.

thanks


The best thing to do is to save the uid or user_id of the user if he/she has your app already by then you can create some validation if the user already exists in the db. . .


You can tackle this in a lot of different ways, but my first suggestion would be to use some JS on the client side to check if a session already exists (which means the users has already authorized your application) and then hide the login button/change the target of the action/do something that prevents user_add.php from being targeted.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜