S
|
swanside 11/20/2008 |
You can do it in your sql database. Set the field to Unique |
J
|
Jane 11/20/2008 |
Hi, global $conn; $strSQLExists = "select * from tbl_customers where name='".$values["name"]."'"; $rsExists = db_query($strSQLExists,$conn); $data=db_fetch_array($rsExists); if($data) { // if record exists do something echo $values["name"]." is already in the system"; return false; } else { // if dont exist do something else return true; } |
K
|
Khris 1/16/2009 |
How would I generate a popup window to say "This customer already exists....." with an OK button, to be used with the code above? |
![]() |
vin7102 1/16/2009 |
Hi wfcentral, global $conn; $strSQLExists = "select * from tbl_customers where name='".$values["name"]."'"; $rsExists = db_query($strSQLExists,$conn); $data=db_fetch_array($rsExists); if($data) { // if the record exists $message="<div class=message><<< "."Database NOT updated ......The name entered already exists.....Use another name"." >>></div>"; return false; } else { // add this next line if needed otherwise delete $values["name"]=strtoupper($values["name"]); return true; } |
K
|
Khris 1/16/2009 |
Perfect! This works just as well as a popup. |