1
0
mirror of https://github.com/fspc/Yellow-Bike-Database.git synced 2025-02-22 08:53:23 -05:00

Corrects error checking for middle name.

When and existing contact was updated it would produce an error that the
contact already existed, and a new middle name needed to be used, also when
created a contact without adding a first and/or last name the same error was
produced.  This fix corrects that bug.
This commit is contained in:
Jonathan Rosenbaum 2016-05-09 04:19:05 +00:00
parent e7120a042a
commit 2d3a184e84
2 changed files with 12 additions and 10 deletions

View File

@ -70,7 +70,7 @@ $(function(){
// test whether patron's name already exists // test whether patron's name already exists
$.post("json/contact.php", {first_name: first_name.val(), middle_initial: middle_initial.val(), $.post("json/contact.php", {first_name: first_name.val(), middle_initial: middle_initial.val(),
last_name: last_name.val(), test_name: 1 }, function(data) { last_name: last_name.val(), contact_id: contact_id, test_name: 1 }, function(data) {
if(data === "1") { if(data === "1") {
err6 = error_handler(0, last_name_error, "","*Your name already exists, please choose a different middle initial.",e); err6 = error_handler(0, last_name_error, "","*Your name already exists, please choose a different middle initial.",e);

View File

@ -11,15 +11,17 @@ $ssl_certificate = SSL_CERTIFICATE;
// test whether patron's name already exists // test whether patron's name already exists
if (isset($_POST['test_name'])) { if (isset($_POST['test_name'])) {
$query = 'SELECT first_name, middle_initial, last_name FROM contacts WHERE ' . if( $_POST['contact_id'] === "new_contact" && $_POST['first_name'] && $_POST['last_name'] ) {
'first_name="' . $_POST['first_name'] . '" AND middle_initial="' . $_POST['middle_initial'] . $query = 'SELECT first_name, middle_initial, last_name FROM contacts WHERE ' .
'" AND last_name="' . $_POST['last_name'] . '";'; 'first_name="' . $_POST['first_name'] . '" AND middle_initial="' . $_POST['middle_initial'] .
$sql = mysql_query($query, $YBDB) or die(mysql_error()); '" AND last_name="' . $_POST['last_name'] . '";';
$result = mysql_fetch_assoc($sql); $sql = mysql_query($query, $YBDB) or die(mysql_error());
if ( is_array($result) ) { $result = mysql_fetch_assoc($sql);
echo 1; if ( is_array($result) ) {
} else { echo 1;
echo 0; } else {
echo 0;
}
} }
} }