-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddnewquestioncode.php
47 lines (41 loc) · 1.21 KB
/
addnewquestioncode.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
<?php
$host="localhost";
$username="root";
$password="";
$dbname="iq_analyser";
$conn = new mysqli($host, $username, $password, $dbname);
$conn2 = new mysqli($host, $username, $password, $dbname);
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
if (isset($_POST['questionno'])) {
$questionno = $_POST['questionno'];
}
if (isset($_POST['question'])) {
$question = $_POST['question'];
}
if (isset($_POST['cid'])) {
$cid = $_POST['cid'];
}
if (isset($_POST['tid'])) {
$tid = $_POST['tid'];
}
if (isset($_POST['diff'])) {
$diff = $_POST['diff'];
}
if (isset($_POST['freq'])) {
$freq = $_POST['freq'];
}
$query="select qno from question_details where qno==$questionno";
$result = mysqli_query($conn,$query);
if (($result) == null){
$sql= " insert into question_details (qno,question,difficulty,frequency) values ('$questionno','$question','$diff','$freq'); ";
$sql2="insert into linking(cid,topic_id,qno) values ('$cid','$tid','$questionno')";
}
if ($conn->query($sql) === TRUE and $conn2->query($sql2) === TRUE ) {
echo " QUESTION details inserted successfully";
} else {
echo "didnt meet the credentials required(question number should be unique)";
}
mysqli_close($conn);
?>