Browse code

Created repository.

DoubleBastionAdmin authored on 26/01/2022 20:32:42
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,48 @@
1
+<?php
2
+/**
3
+ *  Copyright (C) 2021  Double Bastion LLC
4
+ *
5
+ *  This file is part of Roundpin, which is licensed under the
6
+ *  GNU Affero General Public License Version 3.0. The license terms
7
+ *  are detailed in the "LICENSE.txt" file located in the root directory.
8
+ */
9
+
10
+session_start();
11
+
12
+if (isset($_POST['s_ajax_call']) && ($_POST['s_ajax_call'] == $_SESSION['validate_s_access'])) {
13
+
14
+
15
+ define('ACCESSCONST', TRUE);
16
+
17
+ require('db-connect.php');
18
+
19
+    $username = $_POST['username'];
20
+    $contactName = $_POST['contact_name'];
21
+
22
+    // Get the id of the user for which we want to update the contact data
23
+    $query1 = $mysqli->query("SELECT id, username, enabled FROM app_users WHERE BINARY username = '$username' AND enabled = 1");
24
+    $queryres = $query1->fetch_array();
25
+    $userID = $queryres[0];
26
+
27
+    // Get the row id from the 'contacts' table, for the current contact
28
+    $query2 = $mysqli->prepare("SELECT id, user_id, contact_name FROM contacts WHERE user_id=? AND contact_name=?");
29
+    $query2->bind_param("is", $userID, $contactName);
30
+    $query2->execute();
31
+    $fetchInfo = $query2->get_result();
32
+    $contactdata = $fetchInfo->fetch_row();
33
+    $contactRowId = $contactdata[0];
34
+    $query2->close();
35
+
36
+    if ($contactRowId != '' && $contactRowId != null && $contactRowId != 'undefined') {
37
+        $CntctDatabaseId = $contactRowId;
38
+        $messagetosend = 'success';
39
+    } else { $CntctDatabaseId = ''; $messagetosend = 'failure'; }
40
+
41
+    $response = array('successorfailure' => $messagetosend, 'cntctDatabaseID' => $CntctDatabaseId);
42
+    echo json_encode($response);
43
+
44
+} else {
45
+    header("Location: roundpin-login.php");
46
+}
47
+
48
+?>