forked from open-austin/council-connect
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert.php
executable file
·63 lines (37 loc) · 1.41 KB
/
insert.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php // insert.php
require_once 'DatabaseUsPsDb.php';
insertAlert ();
//---------------------
function insertAlert () {
$atxcc_db = new Database ('tgregone_atxcc', 'tgregone_atxcc', 'tgregone_atxcc$', 'localhost');
$tag = $_POST ['tag'];
$username = $_POST ['username'];
$mobile = $_POST ['mobile'];
$email = $_POST ['email'];
$userid = $atxcc_db -> getUserId ($username);
$alerts = "";
if ($mobile == 'true') {
$alerts .= 'T';
} // end if ($mobile == 'true')
if ($email == 'true') {
$alerts .= 'E';
} // end if ($email == 'true')
// first check to see if tag alert already exists for the user, and if so update it
$query = 'SELECT idx FROM ac_data WHERE actype=? AND acrefs=? AND ackey=?';
$params = [
'alert', $userid, $tag
];
if ($atxcc_db -> doQueryRow ($query, $params)) {
$query = 'UPDATE ac_data SET acval=? WHERE actype=? AND acrefs=? AND ackey=?';
$params = [
$alerts, 'alert', $userid, $tag
];
$atxcc_db -> doQuery ($query, $params);
} else {
$query = 'INSERT INTO ac_data (actype, acrefs, ackey, acval) VALUES (?,?,?,?)';
$params = [
'alert', $userid, $tag, $alerts
];
$atxcc_db -> doQuery ($query, $params);
} // end if ($row = $atxcc_db -> doQueryRow ($query, $params))
} // end insertAlert ()