-
Notifications
You must be signed in to change notification settings - Fork 0
/
subs.php
36 lines (30 loc) · 802 Bytes
/
subs.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
<?php
// var_dump($_GET["category"]);
// while ($_GET["category"] != null) {
// echo $_GET["category"];
// }
$cate = array();
$cate = $_GET["category"];
$email = $_GET["email"];
// var_dump($cate);
$servername = "localhost";
$username = "root";
$password = "root";
$dbname = "asgn3";
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
for ($i=0; $i < sizeof($cate); $i++) {
$sql = "insert into subs(topic, user_email) values('$cate[$i]','$email');";
if ($conn->query($sql) === TRUE) {
echo "Successfully subscribed to ".$cate[$i]."<br>";
}
else {
echo "You are already subscribed to ".$cate[$i]."<br>";
}
}
$conn->close();
?>