Jump to content

Archived

This topic is now archived and is closed to further replies.

Mutley

Error if entry already exists

Recommended Posts

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?

Share this post


Link to post
Share on other sites
By making the column [b]unique[/b], then checking for the error, so you can do something else if the error is trggered!


me!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
CREATE TABLE IF NOT EXISTS Users(
  uname VARCHAR(16) NON NULL,
  ...
  UNIQUE(uname)
  );

http://dev.mysql.com/doc/refman/4.1/en/create-table.html

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.