This topic is locked
[SOLVED]

 Avoid duplicate phone numbers

5/11/2011 7:08:26 AM
PHPRunner General questions
E
epanc author

Hi, I'm using the following code in "Before record added" to avoid duplication.

It works well, only I would find a way to preclude judicial fields null. In fact, if there are two records with the field is null the query true. Thanks.
global $conn;

$strSQLExists = "select VacatureBron from _bedrijven where VacatureBron='".$values["VacatureBron"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

echo "<center><b><font color=red>Company already exists in database!</font></b></center>";

return false;

}

J
Jane 5/11/2011

You can check entered value before:

if ($values["VacatureBron"])

{

global $conn;

$strSQLExists = "select VacatureBron from _bedrijven where VacatureBron='".$values["VacatureBron"]."'";

$rsExists = db_query($strSQLExists,$conn);

$data=db_fetch_array($rsExists);

if($data)

{

echo "<center><b><font color=red>Company already exists in database!</font></b></center>";

return false;

}

}
E
epanc author 5/11/2011

it works! Thanks!