-
-
Notifications
You must be signed in to change notification settings - Fork 26
/
ask.php
119 lines (103 loc) · 5.27 KB
/
ask.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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
session_start();
include('connect.php');
if(!isset($_SESSION['user']))
header("location: login.php");
?>
<!DOCTYPE html>
<html>
<head>
<title> Interrogate </title>
<link type="text/css" rel="stylesheet" href="css/style.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link type="text/css" rel="stylesheet" href="css/material.css">
<link type="text/css" rel="stylesheet" href="fonts/font.css">
<link rel="icon" href="images/icon1.png" >
</head>
<body id="ask">
<!-- navigation bar -->
<a href="index.php">
<div id="log">
<div id="i">i</div><div id="cir">i</div><div id="ntro">nterrogate</div>
</div>
</a>
<ul id="nav-bar">
<a href="index.php"><li>Home</li></a>
<a href="categories.php"><li>Categories</li></a>
<a href="contacts.php"><li>Contact</li></a>
<a href="ask.php"><li id="home">Ask Question</li></a>
<a href="profile.php"><li>Hi, <?php echo $_SESSION["user"]; ?></li></a>
<a href="logout.php"><li>Log Out</li></a>
</ul>
<!-- content -->
<div id="content">
<div id="sf">
<center>
<div class="heading ask">
<h1 class="logo"><div id="i">i</div><div id="cir">i</div><div id="ntro">nterrogate</div></h1>
<p id="tag-line">where questions are themselves the answers</p>
</div>
<form action="<?php echo htmlspecialchars( $_SERVER["PHP_SELF"] ); ?>" method="post" enctype="multipart/form-data">
<input name="question" type="text" title="Your Question..." placeholder="Ask Your question on our Community for greate user expereince..." id="question">
<select name="cat">
<option valus="Category">Category</option>
<option value="Algorithms">Algorithms</option>
<option value="Architecture">Architecture</option>
<option value="Theory Of Computation">TOC</option>
<option value="Database Management">DBMS</option>
<option value="Probability & Queuing">PQT</option>
<option value="Software Engineering">SE</option>
<option value="Other">Other</option>
</select>
<input name="submit" type="submit" class="up-in" id="ask_submit">
</form>
</center>
</div>
</div>
<div id="ask-ta">
<h1>Thank You.<br>Stay tunned for updates.</h1>
</div>
<?php
if( isset( $_POST["submit"] ) )
{
function valid($data){
$data=trim(stripslashes(htmlspecialchars($data)));
return $data;
}
$question = valid( $_POST["question"] );
$no = valid( $_POST["cat"]);
$question = addslashes($question);
$q = "SELECT * FROM quans WHERE question = '$question'";
$result = mysqli_query($conn,$q);
if(mysqli_error($conn))
echo "<script>window.alert('Some Error Occured. Try Again or Contact Us.');</script>";
else if( $no == "Category"){
echo "<script>window.alert('Choose a Category.');</script>";
}
else if( mysqli_num_rows($result) == 0 ){
$query = "INSERT INTO quans VALUES(NULL, '$question', NULL,'".$_SESSION['user']."',NULL)";
$query1 = "INSERT INTO quacat SELECT q.id, c.name FROM quans as q, category as c WHERE q.question = '".$question."' AND c.name = '".$_POST['cat']."'";
mysqli_query( $conn, $query);
if(mysqli_query( $conn, $query1)){
echo "<style>#sf{display: none;} #ask-ta{display:block;}</style>";
}
else{
echo "<script>window.alert('Some Error Occured. Try Again or Contact Us.');</script>";
}
}
else{
echo "<script>window.alert('Question was already Asked. Search it on Home Page.');</script>";
}
mysqli_close($conn);
}
?>
<!-- Footer -->
<div id="footer" style="padding:30px;">
© 2017 • Interrogate Inc.
</div>
<!-- Sripts -->
<script src="https://code.jquery.com/jquery-3.2.1.min.js" integrity="sha256-hwg4gsxgFZhOsEEamdOYGBf13FyQuiTwlAQgxVSNgt4=" crossorigin="anonymous"></script>
<script>window.jQuery || document.write('<script type="text/javascript" src="js/jquery-3.2.1.min.js"><\/script>')</script>
<script type="text/javascript" src="js/script.js"></script>
</body>
</html>