forked from if-itb/IF3110-2015-T1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd_question.php
38 lines (35 loc) · 898 Bytes
/
add_question.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
<!DOCTYPE html>
<html>
<head>
<title>Add Question</title>
<meta http-equiv="refresh" content="0; URL='home.php'">
</head>
<body>
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "wbd";
$name = $_POST["nama"];
$email = $_POST["email"];
$topic = $_POST["topik"];
$content = $_POST["konten"];
$id = $_POST["id"];
// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if ($id == 0) {
$sql = "INSERT INTO pertanyaan (Nama, Email, Topik, Konten)
VALUES ('$name', '$email', '$topic', '$content')";
} else {
$sql = "UPDATE pertanyaan SET Nama='$name', Email='$email', Topik='$topic', Konten='$content'
WHERE ID = '$id'";
}
mysqli_query($conn, $sql);
mysqli_close($conn);
?>
</body>
</html>