-
Notifications
You must be signed in to change notification settings - Fork 0
/
tagUpdate.php
55 lines (49 loc) · 1.52 KB
/
tagUpdate.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
<?php
//+++++++++++++++++++++++++++++++++++++++++++++++++
//This page is used for updating and retrieving tags
//for a user
//+++++++++++++++++++++++++++++++++++++++++++++++++
include("check_login.php");
include("search.php");
//initialize variables
//Tag variable used for updating tags
$tag = "";
//Stores userID that is passed
$userID = "";
//Stores tag type
$tagType = "";
//Check POST variables to assign values
if (isset($_POST['userID'])) {
$userID = $_POST['userID'];
};
if (isset($_POST['tag'])) {
$tag = $_POST['tag'];
};
if (isset($_POST['tagType'])) {
$tagType = $_POST['tagType'];
};
//+++++++++++++++++++++++++++++++++++++++++++++++++
//Insert tags for a given user
//+++++++++++++++++++++++++++++++++++++++++++++++++
function update_tags($tag,$userID,$tagType) {
$servername = "127.0.0.1";
$username = "who_what";
$password = "who_what";
$dbname = "who_what";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "INSERT into tbl_tags (tag,tagType,userID) VALUES ('".$tag."','".$tagType."','".$userID."')";
$result = $conn->query($sql);
$conn->close();
}
//Check for mandatory tag fields and insert.
//Once inserted, echo the new tag set
if (isset($_POST['tag']) && isset($_POST['userID'])){
update_tags($tag,$userID,$tagType);
echo get_tags($userID);
}
?>