Jump to content

Archived

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

leeroy1

checking for duplicates

Recommended Posts

Is it possible to execute a sql statement or something in order to check if a field a user has enter already exists in a table, and if it does tells the user and does not try to submit the form? Or is there a better way to do this?

Share this post


Link to post
Share on other sites

i think mysql statement can already detect if a certain user enters a field that already exists. I has a prompt saying "Duplicate entry" on it. If u want it more formal, you may add message box on it using javascript.

 

hope this help :mellow:

Share this post


Link to post
Share on other sites

Do you mean looking for a value and telling the user if it already exists?

 

$result = mysql_query("SELECT column_name FROM tbl_name WHERE column_name='$value'");

if (!mysql_num_rows($result > 0) {
// code here
}

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.