phpMyAdmin - Block Duplicate Submissions

I’m using PHP5 and I have a directory where people can submit websites.

Is there a simple built in phpMyAdmin setting to block duplicate submissions?

So, quite simply all that I need to do is have the URL row checked for duplicates and if the URL already exists in the db block the duplicate submission altogether.

I’ve of course Googled this, however the only promising how-to’s assume that you have a lot of back-end knowledge already, which I do not… I’m a front-end guy.

Thanks

It would have to be a back-end function to do this.

  1. query the database and search for the domain name
  2. if found display error.

Depending on how your form is setup it should be more than a few extra lines of code.

Create a unique index on the URL column, and use INSERT IGNORE when inserting data :slight_smile:

if people can submit urls, and more than one person can submit the same url, do you want to keep track of who first submitted it, or who last submitted it, or how many people submitted it?

or are you only keeping the url itself regardless of who submitted it?

I think this is probably the best solution. It doesn’t matter who submits a URL, the date or anything else. A URL should be submitted once and if accepted, any future duplicate submissions should just be blocked altogether.

So here’s what I’m seeing for the URL index:

ALTER TABLE `Listings` ADD INDEX(`URL`)

What exactly should I make that before I click “Go”?

calmestghost, that will create an index on the table but not a unique one.

The syntax you’re after is CREATE UNIQUE INDEX unique_url ON Listings(URL);

That’s a good solution for now, I’ll have to work out a custom error message though. We can call this one solved. Thank you very much for your help everyone.

If you’re using PHP you can use the mysql_affected_rows function to test whether an insert has been successful or not.