-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquestion_insert.php
More file actions
38 lines (26 loc) · 878 Bytes
/
Copy pathquestion_insert.php
File metadata and controls
38 lines (26 loc) · 878 Bytes
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
<?php session_start() ?>
<?php
include("function.php");
$conn=connect();
if(isset($_SESSION['loggedin']) && $_SESSION['loggedin']==true){
//echo "".$_SESSION['username']."<br>";
//echo "".$_SESSION['id'];
$title=mysqli_real_escape_string($conn,$_POST['title']);
$description=mysqli_real_escape_string($conn,$_POST['description']);
$category=$_POST['category'];
$user_id=$_SESSION['id'];
echo "<br>$title<br>$description<br>$category<br>";
$sql="insert into question(title,question,category,user_id) values('$title','$description','$category','$user_id')";
if(mysqli_query($conn,$sql)){
$msg=urlencode("Question inserted successfully");
header("Location:questionList.php?QuestionInserted=".$msg);
}
else{
echo "failed ".mysqli_error($conn);
}
}
else{
$msg=urlencode("please log in first");
header("Location:login.php?LoginBeforePost=".$msg);
}
?>