-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeleteKeyword.php
37 lines (25 loc) · 1.14 KB
/
deleteKeyword.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
<?php
session_start();
$servername = "localhost";
$username = "root"; //Eneter Username for ESSCC Earthquake DB
$database="moose-pirates";
$password="MYPASSWORD123";
// Create connection
$conn = new mysqli($servername, $username, $password);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
mysqli_select_db( $conn, "moose-pirates") or die( "Unable to select database");
$keyword = $_GET['keyword'];
file_put_contents('function.log', date('H:i:s') . __FUNCTION__ . __LINE__ . print_r($keyword , true) . "\n", FILE_APPEND);
$query = "DELETE FROM user_keywords WHERE id IN (SELECT id from users where email = '". $_SESSION['user']."') AND keyword = '".$keyword."'";
$result = mysqli_query($conn, $query);
file_put_contents('function.log', date('H:i:s') . __FUNCTION__ . __LINE__ . print_r($result , true) . "\n", FILE_APPEND);
if (!$result) {
$error = mysqli_error($conn);
header("location: settings.php?status=error&message=". urlencode($error) ."");
}
$message = "Keyword Removed";
header("location: settings.php?status=success&message=". urlencode($message) ."");
?>