forked from if-itb/IF3110-2015-T1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-answer.php
28 lines (21 loc) · 917 Bytes
/
add-answer.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
<?php
include 'dbfunctions.php';
$conn=ConnectToDatabase();
if(isset($_POST['submit_answer'])) {
$answer_name = $_POST["answer_name"];
$answer_email = $_POST["answer_email"];
$answer_content = $_POST["answer_content"];
$id = $_GET["id"];
$name_temp = mysqli_real_escape_string($conn,$answer_name);
$email_temp = mysqli_real_escape_string($conn,$answer_email);
$content_temp = mysqli_real_escape_string($conn,$answer_content);
$id_temp = mysqli_real_escape_string($conn,$id);
$sql = "INSERT INTO Answer (question_id, answer_name, answer_email, answer_content, answer_vote, answer_date)
VALUES ('$id_temp', '$name_temp', '$email_temp', '$content_temp', 0, now())";
if (!mysqli_query($conn, $sql)) {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
$answer_id = mysqli_insert_id($conn);
header("Location: question-page.php?id=". $id);
}
?>