forked from DBrider3/GB-SNS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
answer_ok.php
33 lines (26 loc) · 947 Bytes
/
answer_ok.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
<!DOCTYPE html>
<meta charset="utf-8" />
<?php
session_start();
include 'sql.php';
$conn = sql();
if(!isset($_SESSION['user_id'])) {
echo "<meta http-equiv='refresh' content='0;url=login.php'>";
exit;
}
$user_id = $_SESSION['user_id'];
if(!isset($_POST['question_ix']) || !isset($_POST['contents'])) exit;
$question_ix = $_POST['question_ix'];
$contents = $_POST['contents'];
$sql = "INSERT INTO answer (question_ix , contents) VALUES ('$question_ix','$contents')";
// user_id 넣을까 말까
if ($conn->query($sql) === TRUE) {
$conn->close();
print("success");
print "<script language=javascript> alert('question success'); location.replace('./question_detail.php?ix=$question_ix'); </script>";
} else {
$conn->close();
echo "failed";
print "<script language=javascript> alert(\"question failed $conn->error\"); location.replace('./question_detail.php?ix=$question_ix'); </script>";
}
?>