-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathquestion_process_part3.php
79 lines (72 loc) · 2.56 KB
/
question_process_part3.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
<?php
session_start();
include 'admin/json/settings.php';
$id=$_SESSION['user_id'];
$obj1 = new commonFunctions();
$dbh = $obj1->dbh;
$status = false;
$row = '';
$query = $dbh->prepare("select * from pig_questions where peradd='0' order by id asc");
$query->execute();
$counts_questions=$query->rowCount();
if ($query->rowCount() > 0)
{
$status = true;
while($row = $query->fetch(PDO::FETCH_ASSOC))
{
if($row['type']==1)
{
$answer=$_REQUEST['optionsRadios'.$row['id']];
}
else if($row['type']==2)
{
$answer=$_REQUEST['txt'.$row['id']];
}
else if($row['type']==3)
{
$answer=$_REQUEST['options'.$row['id']];
}
else if($row['type']==4)
{
$answer=$_REQUEST['dropdownval'.$row['id']];
}
$_SESSION['qn']['question'.$row['id']]=array("question_id"=>$row['id'],"type"=>$row['type'],"answer"=>$answer);
}
if(!empty($_SESSION['qn']))
{
$obj3 = new commonFunctions();
$dbh1 = $obj3->dbh;
$query1 = $dbh1->prepare("insert into pig_user_answer_rel(`user_id`) values(:id)");
$query1->bindParam(":id",$id,PDO::PARAM_INT);
$query1->execute();
$propertyId = $dbh1->lastInsertId();
foreach ($_SESSION['qn'] as $value)
{
$obj3 = new commonFunctions();
$dbh3 = $obj3->dbh;
$question_id=$value['question_id'];
$answer=$value['answer'];
$type=$value['type'];
$query3 = $dbh->prepare("insert into pig_user_answer (`question_id`,`answer`,`question_type`,`user_id`,`property_id`) values(:question_id,:answer,:type,:id,:propertyId)");
$query3->bindParam(":question_id",$question_id,PDO::PARAM_INT);
$query3->bindParam(":answer",$answer,PDO::PARAM_STR);
$query3->bindParam(":type",$type,PDO::PARAM_INT);
$query3->bindParam(":id",$id,PDO::PARAM_INT);
$query3->bindParam(":propertyId",$propertyId,PDO::PARAM_INT);
$query3->execute();
//
}
$_SESSION['qn']='';
$_SESSION['valid_user']='set';
$_SESSION['user_id']=$id;
echo "1";
}
else
{
echo "0";
}
}
else
{
}
?>