1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

facebook and site login. Best way to avoid duplicate email.

Discussion in 'PHP' started by showgun, Apr 8, 2014.

  1. #1
    I've been working on a project for a while. I have implemented a site login system already that was the original plan. A friend of mine suggested that i should let users to login using their facebook account. I looked into this a few days ago but i don't really know how i could avoid duplicate email to be used. Example. Somebody register on the site with email: created an account and forgets about it. Few months or years later comes back to the site and this time uses his facebook account to login. He registered his facebook account with the same email that he used when first registered on my site. So if i insert this email into database then it will be duplicate. What is the best practise to avoid this situation?
    showgun, Apr 8, 2014 IP
  2. AbstractChaos

    AbstractChaos Member

    Likes Received:
    Best Answers:
    Trophy Points:
    The facebook API on login will give you the users email (there may be a permission required first).

    compare the fb email to one on your system if exists it is the same person and should be treated as such (possibly just update the row with a fb id or if you want to allow many Accounts (FB,Email,Google,Twitter) to one Profile (A user on your site), insert a new account for that user)

    AbstractChaos, Apr 8, 2014 IP
  3. humanwebs

    humanwebs Greenhorn

    Likes Received:
    Best Answers:
    Trophy Points:
    You can use the following scenario

    i. If a new user is registering using facebook

    1. Check if a email is already existing

    1, If not exist, its simple just insert their email, facebook id which is more important, their profile picture etc..

    2, If the email already exist then match the email and update the facebook id and other details for the particular email or the field.

    ii. If user is logging using facebook once again

    You should not check the email id once again, since facebook provides option to change your email id so you need to check the facebook id with the one already existing in the and then allow them to your account.

    Hope this should be useful for you :)
    humanwebs, Apr 18, 2014 IP