69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
|
<?php
|
||
|
include('includes/config/config.php');
|
||
|
include('log_entry.php');
|
||
|
include ('includes/functions.php');
|
||
|
error_log ( "Start Printing Request Attributes" );
|
||
|
$requestStr="";
|
||
|
foreach ( $_REQUEST as $key => $value ) {
|
||
|
$requestStr.=$key . " : " . $value . "\n";
|
||
|
error_log ( $key . " : " . $value . "<br />\r\n" );
|
||
|
}
|
||
|
error_log ( "End Printing Request Attributes" );
|
||
|
save_log($requestStr,'Questionnaire Covid','SAVE','save_covid_wah.php');
|
||
|
$id = $_POST['id'];
|
||
|
$question =$_POST['question'];
|
||
|
$question_hindi =$_POST['question_hindi'];
|
||
|
$type = $_POST['type'];
|
||
|
$sequence = $_POST['sequence'];
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
if(!empty($id)){
|
||
|
$query = "update covid_wah_questions set question = '$question',question_hindi = '$question_hindi', type = '$type', sequence = '$sequence', modified_by = '".$_SESSION['user_id']."' where id = '".$id."'";
|
||
|
}
|
||
|
else {
|
||
|
$query = "insert into covid_wah_questions(question,question_hindi,type,sequence, modified_by)
|
||
|
values ('$question','$question_hindi', '$type','$sequence','".$_SESSION['user_id']."' ); ";
|
||
|
}
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
else{
|
||
|
|
||
|
|
||
|
$query = "select max(id) id from covid_wah_questions ";
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
if(mysqli_num_rows($result) > 0) {
|
||
|
while ($row = @mysqli_fetch_assoc($result)) {
|
||
|
|
||
|
$id_max = $row['id'];
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
$query = "select * from covid_wah_questions where id='".$id_max."'";
|
||
|
//echo $query;
|
||
|
if (!$result = @mysqli_query($conn,$query)) {
|
||
|
exit(mysqli_error($conn));
|
||
|
}
|
||
|
if(mysqli_num_rows($result) > 0) {
|
||
|
while ($row = @mysqli_fetch_assoc($result)) {
|
||
|
|
||
|
$data=$row;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
if($data==null)
|
||
|
{
|
||
|
$data['status'] = 200;
|
||
|
$data['message'] = "Data not found!";
|
||
|
}
|
||
|
echo json_encode($data);
|
||
|
?>
|