-
Notifications
You must be signed in to change notification settings - Fork 2
/
add_question.php
66 lines (53 loc) · 2.01 KB
/
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
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
<?php
include_once("header.php");
include_once("bad_words.php");
$error_msg = "";
if(isset($_GET['error'])){
$error_msg = $_GET['error'];
}
$success_msg = "";
if(isset($_GET['success'])){
$success_msg = $_GET['success'];
}
$heading="";
$content="";
$user_id="";
if(isset($_POST['add_qn'])){
$heading=$_POST['heading'];
$content=$_POST['content'];
$user_id=$_SESSION['user_id'];
$time = date('Y-m-d H:i:s');
if (check_badwords($content)=='abused_failed_123' || check_badwords($heading)=='abused_failed_123'){
echo '<script>alert("Offensive words found! Unable to post your question.")</script>';
} else {
$query = "INSERT INTO tbl_questions (`user_id`,`heading`,`content`,`upvote`,`downvote`,`marked`,`time`) VALUES('$user_id','$heading','$content','0','0','0','$time')";
$results = mysqli_query($db,$query);
}
}
?>
<section class="questions">
<div class="container">
<div class="row">
<form action="" method="post">
<div class="form-group">
<label for="heading">Heading</label>
<input type="text" class="form-control" name="heading" id="heading" required>
</div>
<div class="form-group">
<label for="content">Question</label>
<textarea class="form-control" name="content" id="content" rows="3" required></textarea>
</div>
<div class="form-group row">
<div class="col-sm-12">
<input type="submit" name="add_qn" class="btn btn-primary" style="" value="Add Question">
</div>
</div>
</form>
</div>
</div>
</section>
<!-- Bootstrap core JavaScript -->
<script src="vendor/jquery/jquery.min.js"></script>
<script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script>
</body>
</html>