Results 1 to 4 of 4

Thread: SQL query for user login

  1. #1
    Join Date
    Jan 2009
    Posts
    638

    SQL query for user login

    Either the following query:

    Code:
    INSERT INTO users (login, fullName, email) VALUES ('".$login."', '".$fullName."', '".$email."');

    I'd like to insert the user data if and only if a login with the name foo is not in the table.

    I tried:

    Code:
    INSERT INTO users (login, fullName, email) VALUES ('".$login."', '".$fullName."', '".$email."') on duplicate key update login='foo';

    But it always gives me a line of registration.

  2. #2
    Join Date
    May 2008
    Posts
    271

    Re: SQL query for user login

    It would not be easier to verify, before the login, that a user already exists in the table. If true then we do nothing, if false, it adds the line.

  3. #3
    Join Date
    Jan 2009
    Posts
    638

    Re: SQL query for user login

    That's what I did. I built a test first with a select.

    An alternative as the login, in my environment, is unique was to be a unique identifier on the field with a login error handling behind.

  4. #4
    Join Date
    May 2008
    Posts
    685

    Re: SQL query for user login

    If you have developed an application in PHP I strongly suggest you phpDoctrine to define a layer of abstraction on top of your database. This allows for example to avoid such problems or you even create your request.

Similar Threads

  1. Replies: 6
    Last Post: 29-03-2015, 08:39 PM
  2. Replies: 6
    Last Post: 09-02-2011, 12:39 AM
  3. iPad Dual Login (Multiple User Login)
    By Netorious in forum Portable Devices
    Replies: 6
    Last Post: 22-05-2010, 09:44 AM
  4. Days Since Last Login IN ADUC Query
    By sivaranjan in forum Active Directory
    Replies: 4
    Last Post: 10-03-2008, 04:55 PM
  5. Windows XP, User login box, domain user how to auto populate.
    By sivaranjan in forum Windows XP Support
    Replies: 3
    Last Post: 18-01-2008, 11:12 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,554,105.03317 seconds with 17 queries