Jump to content


Photo

Error if entry already exists


  • Please log in to reply
4 replies to this topic

#1 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 05 October 2006 - 02:46 PM

How do I make it so when your submitting information using a form, that if the data in the database already exists, it comes up with an error?
~ Mutley.

#2 printf

printf
  • Staff Alumni
  • Advanced Member
  • 889 posts

Posted 05 October 2006 - 02:49 PM

By making the column unique, then checking for the error, so you can do something else if the error is trggered!


me!

#3 Mutley

Mutley
  • Members
  • PipPipPip
  • Advanced Member
  • 765 posts

Posted 05 October 2006 - 03:28 PM

How do you mena unique? Do you have an example?
~ Mutley.

#4 Hi I Am Timbo

Hi I Am Timbo
  • Members
  • PipPipPip
  • Advanced Member
  • 109 posts

Posted 05 October 2006 - 03:49 PM

You would set the column to unique in the database.  It is a property of fields. 

If you use PHPMyAdmin, it is the blue U when creating / modifying a field.

#5 roopurt18

roopurt18
  • Staff Alumni
  • Advanced Member
  • 3,749 posts
  • LocationCalifornia, southern

Posted 05 October 2006 - 04:18 PM

CREATE TABLE IF NOT EXISTS Users(
  uname VARCHAR(16) NON NULL,
  ...
  UNIQUE(uname)
  );

http://dev.mysql.com...eate-table.html
PHP Forms : Part I | Part II

JavaScript: Singleton

http://www.rbredlau.com




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users