I have a database with 2 UNIQUE columns for phone and email.
it's working to block duplicate entries, however I'm having a problem managing the error message to something that will make sense to the user.
Here is the code I have so far.
PHP Code:
<?php
$dbinsert = false;
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
// sest store location to dictate which table to post to
$storetable = $_POST['store'];
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "regForm")) {
$insertSQL = sprintf("INSERT INTO {$storetable} (first_name, last_name, email, phone) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['first_name'], "text"),
GetSQLValueString($_POST['last_name'], "text"),
GetSQLValueString($_POST['email'], "text"),
GetSQLValueString($_POST['phone'], "text"));
mysql_select_db($database_Registration, $Registration);
$Result1 = mysql_query($insertSQL, $Registration) or die(mysql_error());
$insertGoTo = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
How do I overwrite the default error message with one that would use something like this to plug back into the page
PHP Code:
if ($Result1) {
$dbinsert = true;
}
if (!$Result1) {
$error['already_reg'] = 'The email or phone that you entered is already registered. You can only enter once. If you feel that this is an error, please contact the webmaster at bugs@digitaledgecc.com.';
}
help?