query("SELECT id, username, enabled FROM app_users WHERE BINARY username = '$username' AND enabled = 1"); $queryres = $query1->fetch_array(); $userID = $queryres[0]; // Get the row id from the 'contacts' table, for the current contact $query2 = $mysqli->prepare("SELECT id, user_id, contact_name FROM contacts WHERE user_id=? AND contact_name=?"); $query2->bind_param("is", $userID, $contactName); $query2->execute(); $fetchInfo = $query2->get_result(); $contactdata = $fetchInfo->fetch_row(); $contactRowId = $contactdata[0]; $query2->close(); if ($contactRowId != '' && $contactRowId != null && $contactRowId != 'undefined') { $CntctDatabaseId = $contactRowId; $messagetosend = 'success'; } else { $CntctDatabaseId = ''; $messagetosend = 'failure'; } $response = array('successorfailure' => $messagetosend, 'cntctDatabaseID' => $CntctDatabaseId); echo json_encode($response); } else { header("Location: roundpin-login.php"); } ?>