Go Back   TechArena Community > Software > Software Development
Become a Member!
Forgot your username/password?
Tags Active Topics RSS Search Mark Forums Read

Reply
 
Thread Tools Search this Thread
  #1  
Old 30-01-2009
Member
 
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.
Reply With Quote
  #2  
Old 30-01-2009
XSI XSI is offline
Member
 
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.
Reply With Quote
  #3  
Old 30-01-2009
Member
 
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.
Reply With Quote
  #4  
Old 30-01-2009
Member
 
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.
Reply With Quote
Reply

  TechArena Community > Software > Software Development
Tags: , ,



Thread Tools Search this Thread
Search this Thread:

Advanced Search


Similar Threads for: "SQL query for user login"
Thread Thread Starter Forum Replies Last Post
Login Completely Blocked w/User Profile Service Failed the Login RaeS Vista Help 6 09-02-2011 12:39 AM
How to make Windows 7 show user list on login screen and not just the last logged on user shyman Operating Systems 5 05-08-2010 12:56 PM
iPad Dual Login (Multiple User Login) Netorious Portable Devices 6 22-05-2010 09:44 AM
Days Since Last Login IN ADUC Query sivaranjan Active Directory 4 10-03-2008 04:55 PM
Windows XP, User login box, domain user how to auto populate. sivaranjan Windows XP Support 3 18-01-2008 11:12 PM


All times are GMT +5.5. The time now is 11:51 AM.