function compare_contacts($arrayOfContacts, $sourceID) { $matchedContacts = array(); foreach ($arrayOfContacts as $contact) { if ($DestinationID = checkDatabaseForUser($contact['number'])) { //Check if Contact pair alrady exist and if yes get ID $contact['id'] = $DestinationID; if ($existingContactID = checkDatabaseForContact($sourceID, $DestinationID)) { $contact['contactID'] = $existingContactID; } $matchedContacts[] = $contact; } } return $matchedContacts; }
</td> </tr> <tr> <td>Check if user already exist</td> <td><?php if (checkDatabaseForUser('84d89877f0d4041efb6bf91a16f0248f2fd573e6af05c19f96bedb9f882f7882') != 0) { echo "checkDatabaseForUser(): existing User </td><td> <span class='success' style='color:green'>successful</span><br></td>"; } else { echo "checkDatabaseForUser(): existing User </td><td> <span class='notsuccess' style='color:red'>not successful</span><br></td>"; } ?> </tr> <tr> <td>Check if user already exist</td> <td><?php if (checkDatabaseForUser(' ') == 0) { echo "checkDatabaseForUser(): non existing User </td><td> <span class='success' style='color:green'>successful</span><br></td>"; } else { echo "checkDatabaseForUser(): non existing User </td><td> <span class='notsuccess' style='color:red'>not successful</span><br></td>"; } ?> </tr> <tr> <td>Check if a user can be created with valid data</td> <td><?php $mobileNumber = generateRandNumber(12); $password = "******"; if (strpos(create_user($mobileNumber, $password), "OK") === 0) { echo "create_user(): valid data </td><td> <span class='success' style='color:green'>successful</span><br></td>"; } else { echo "create_user(): valid data </td><td> <span class='notsuccess' style='color:red'>not successful</span><br></td>";
<?php include "dbconnection.php"; include "registration.php"; $mobileNumber = $_POST['mobileNumber']; if ($user_id = checkDatabaseForUser($mobileNumber)) { echo "User already exists : " . $user_id; } else { echo register($mobileNumber, generateValidationString(5)); }