forked from if-itb/IF3110-2015-T1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaskme.php
78 lines (74 loc) · 3.43 KB
/
askme.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Simple Stack Exchange : Ask Me</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta charset="utf-8">
<?php require_once('dbconnect.php'); ?>
</head>
<body>
<div id="wrapper">
<div id="header">
<div id="title">
<a href="index.php" class="center"><p>Simple StackExchange</p></a>
</div>
</div>
<?php
$id=-1;
if ($_GET){
$id = $_GET['id'];
}
if ($id !== -1){
$sql = "SELECT
question.id as id,
question.name as name,
question.email as email,
question.qtopic as qtopic,
question.content as content,
question.vote as vote
FROM question WHERE question.id='$id'";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
$result_list = array();
while($row = $result->fetch_assoc()) {
?>
<div class="contents">
<h1><p>What's your question?</p></h1>
<hr>
<div class="formArea">
<form name="qForm" action="updatequestion.php" onsubmit="return validateQForm()" method="post" id="questions_form">
<input type="hidden" name="id" value="<?= $row["id"]?>">
<div><input class="formBar" type="text" name="name" value="<?= $row["name"]?>"></div>
<div><input class="formBar" type="text" name="email" value="<?= $row["email"]?>"></div>
<div><input class="formBar" type="text" name="qtopic" value="<?= $row["qtopic"]?>"></div>
<div><textarea class="formBar" name="content" form="questions_form" rows="8"><?= $row["content"]?></textarea></div>
<input id="postQuestion" type="submit" value="EDIT">
</form>
</div>
</div>
<?php
}
}
} else { ?>
<div class="contents">
<h1><p>What's your question?</p></h1>
<hr>
<div class="formArea">
<form name="qForm" action="insertquestion.php" onsubmit="return validateQForm()" method="post" id="questions_form">
<div><input class="formBar" type="text" name="name" placeholder=" Name"></div>
<div><input class="formBar" type="text" name="email" placeholder=" E-mail"></div>
<div><input class="formBar" type="text" name="qtopic" placeholder=" Question Topic"></div>
<div><textarea class="formBar" name="content" form="questions_form" rows="8" placeholder=" Content"></textarea></div>
<input id="postQuestion" type="submit" value="POST">
</form>
</div>
</div>
<?php
}
$conn->close();
?>
</div>
<script src="js/thescript.js"></script>
</body>
</html>