This repository was archived by the owner on Nov 16, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
97 lines (81 loc) · 3.4 KB
/
index.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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
require_once("config/init.php");
require_once("config/dbqueries.php");
if(!isset($_SESSION['user']))
{
header('location: http://localhost/phpscript/login.php');
}
if($_SERVER['REQUEST_METHOD'] == 'POST')
{
$question = $_POST['question'];
$category = $_POST['category'];
$user_id = $_SESSION['user']->id;
if(addQuestion($question,$user_id,$category,$conn))
{
header('location: http://localhost/phpscript');
}
}
$questions = null;
if(isset($_GET['cat']))
{
$questions = getQuestionByCategory($_GET['cat'],$conn);
}else{
$questions = selectAllQuestions($conn);
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/css?family=Berkshire+Swash" rel="stylesheet">
<title>QAnswers</title>
</head>
<body>
<?php
require_once("template/navbar.view.php");
?>
<div class="container">
<div class="row">
<div class="col-md-3">
<?php
require_once("template/sidebare.view.php");
?>
</div>
<div class="col-md-9">
<form method="post" action="" >
<div class="question-post">
<textarea name="question" placeholder="What is the best way to learn C?"></textarea>
<div class="question-action">
<div class="row">
<div class="col-xs-8">
<div class="input-group">
<span class="input-group-addon"><i class="glyphicon glyphicon-flag"></i></span>
<select style="width:200px;" class="form-control" name="category">
<?php foreach (getAllCategories($conn) as $key => $value): ?>
<option value="<?= $value->id ?>">ِ<?= $value->name; ?></option>
<?php endforeach; ?>
</select>
</div>
</div>
<div class="col-xs-4">
<input type="submit" value="Add Question" class="btn btn-danger">
</div>
</div>
</div>
</div>
</form>
<?php foreach ($questions as $value):?>
<div class="question-section">
<h4> <a href="single.php?id=<?= $value->id ?>"> <?= $value->question ?>? </a></h4>
<span class="question-info" >Question added by <a href="#" ><?= $value->username ?></a> in <a href="#" > <?= $value->category ?> </a></span>
</div>
<?php endforeach; ?>
</div>
</div>
</div>
</body>
</html>