-
Notifications
You must be signed in to change notification settings - Fork 0
/
removfav.php
64 lines (52 loc) · 1.55 KB
/
removfav.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
63
64
<!DOCTYPE html>
<html>
<head>
<title>Poodle</title>
<table align="right"><br>
<tr><td align="right"><form action="search.php" method="get" >
<input type="text" size="40" name="keyword" ><input type="submit" name="sub" value="Explore" />
</form>
</td></tr></table>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<?php include "master.php"; ?>
</head>
<body>
<?php
session_start();
$doc_id = $_REQUEST["id"];
#echo $_SESSION["var"];
$servername="localhost";
$username="admin";
$pass="monarchs";
$db="userlog";
$conn=mysqli_connect($servername,$username,$pass,$db);
if($conn->connect_error){
die("Connection failed:".$conn->connect_error);
}
#else echo"Successfully connected to the database!<br>";
if(empty($doc_id))
echo "Failure to fetch doc id!<br>";
else
{
$uId = $_SESSION['uId'];
$sql="SELECT * FROM favourites WHERE uname = '{$uId}' AND doc_id = '{$doc_id}' ";
$result = $conn->query($sql);
$rows = @ mysqli_num_rows($result);
if ($rows>0)
{
$row = mysqli_fetch_array($result);
$row_id = $row["id"];
$delete= "DELETE FROM favourites WHERE uname = '{$uId}' AND doc_id = '{$doc_id}'";
$result = $conn-> query($delete);
echo "Successfully Removed";
echo "<a href='http://localhost/Poodle.com/collections.php'><br>Go to Collections <a/>";
}
else
{
echo "Unable to locate the item in the database ";
echo "<a href='http://localhost/Poodle.com/collections.php'><br>Go to Collections <a/>";
}
}
?>
</body>
</html>