Browse Source

Fixes #28.

devel
Jonathan Rosenbaum 7 years ago
parent
commit
beeab5e775
  1. 1
      js/contact.js
  2. 4
      json/contact.php

1
js/contact.js

@ -69,6 +69,7 @@ $(function(){
err1 = error_handler(last_name.val(), last_name_error, "","*Required",e); err1 = error_handler(last_name.val(), last_name_error, "","*Required",e);
// test whether patron's name already exists // test whether patron's name already exists
// and if name matches a different contact_i
$.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(), contact_id: contact_id, test_name: 1 }, function(data) { last_name: last_name.val(), contact_id: contact_id, test_name: 1 }, function(data) {

4
json/contact.php

@ -12,12 +12,12 @@ $ssl_certificate = SSL_CERTIFICATE;
if (isset($_POST['test_name'])) { if (isset($_POST['test_name'])) {
if( $_POST['first_name'] && $_POST['last_name'] ) { if( $_POST['first_name'] && $_POST['last_name'] ) {
$query = 'SELECT first_name, middle_initial, last_name FROM contacts WHERE ' . $query = 'SELECT first_name, middle_initial, last_name, contact_id FROM contacts WHERE ' .
'first_name="' . $_POST['first_name'] . '" AND middle_initial="' . $_POST['middle_initial'] . 'first_name="' . $_POST['first_name'] . '" AND middle_initial="' . $_POST['middle_initial'] .
'" AND last_name="' . $_POST['last_name'] . '";'; '" AND last_name="' . $_POST['last_name'] . '";';
$sql = mysql_query($query, $YBDB) or die(mysql_error()); $sql = mysql_query($query, $YBDB) or die(mysql_error());
$result = mysql_fetch_assoc($sql); $result = mysql_fetch_assoc($sql);
if ( is_array($result) ) { if ( is_array($result) && ($result["contact_id"] !== $_POST['contact_id']) ) {
echo 1; echo 1;
} else { } else {
echo 0; echo 0;

Loading…
Cancel
Save