-
Notifications
You must be signed in to change notification settings - Fork 0
/
sub.php
49 lines (41 loc) · 945 Bytes
/
sub.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
<?php
function showlist(){
$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);
}
$sql = "select name from topic";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
// output data of each row
while($row = $result->fetch_assoc()) {
$topic = trim($row['name']);
echo "<input type=checkbox name=category[] value=$topic>";
echo $topic;
echo "<br>";
}
}
$conn->close();
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<form method=get action="subs.php">
Enter your email<input type="text" name=email><br>Please choose from the list of topics<br>
<?php
showlist();
?>
<input type="submit" value="Subscribe">
</form>
</body>
</html>