-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsubmitAnswer.php
49 lines (31 loc) · 1.02 KB
/
submitAnswer.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
<?php
//submitAnswer.php is linked to from conversation.php
//and serves to connect to the DB and insert the answer and its details
//into the relevant database.
//error_reporting(0);
echo '<link href="/css/bootstrap.min.css" rel="stylesheet">';
session_start();
include_once 'connect.php';
$questionID=$_GET['askerID'];
$aRating = 0;
// Was using POST ID from answer form for a_id
//$aID = intval($_POST['id']);
$aID = $_SESSION['questionNum'];
$conn = new mysqli($servername, $username, $password, $dbname);
$sql = "INSERT INTO answer (a_id,a_asker, a_content, a_rating)
VALUES ('$aID','$_SESSION[username]', '$_POST[answer]','$aRating')";
if (isset($_POST['submit']))
{
if ($conn->query($sql) === TRUE)
{
//echo "New answer created successfully";
header("Location: index.php");
}
else
{
echo "Error: " . $sql . "<br>" . $conn1->error;
}
}
mysqli_close($conn);
//unset($_SESSION['questionNum']);
?>