MMCT TEAM
Server IP : 2a02:4780:3:1493:0:3736:a38e:7  /  Your IP : 216.73.216.139
Web Server : LiteSpeed
System : Linux sg-nme-web1393.main-hosting.eu 4.18.0-553.40.1.lve.el8.x86_64 #1 SMP Wed Feb 12 18:54:57 UTC 2025 x86_64
User : u926327694 ( 926327694)
PHP Version : 7.4.33
Disable Function : system, exec, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : OFF  |  Python : OFF
Directory (0755) :  /home/u926327694/domains/smsoft.in/public_html/mda/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home/u926327694/domains/smsoft.in/public_html/mda/update-feedback.php
<?php 
include_once("db.php");
if(!isset($_SESSION['userData']))
{
    echo"<script>window.location='index.php';</script>";
    exit;
}
$userData = json_decode($_SESSION['userData'],true);
if(isset($_POST['Data1']))
{
    $field1 = $_POST['Data1'];
    $q=explode("~~",$field1);
    $field = $q[0];
    $stud_id = $q[1];
    $type_id = $q[2];
    $question_id = $q[3];
    $value = $_POST['value'];
    $value=rtrim($value," ");
    
    $sel_result = mysqli_query($con, "select * from FactFeedback_Table where Student_ID = '$stud_id' and Type_ID = '$type_id' and Question_ID = '$question_id'");
    if(mysqli_num_rows($sel_result) > 0) {
        mysqli_query($con, "update FactFeedback_Table set $field = '$value' where Student_ID = '$stud_id' and Type_ID = '$type_id' and Question_ID = '$question_id'");
    }
    else {
        // Generate Q
        $q_result = mysqli_query($con, "SELECT MAX(Q) as max_q FROM FactFeedback_Table");
        $row_q = mysqli_fetch_assoc($q_result);
        $q = ($row_q['max_q'] ?? 0) + 1;
        
        // Generate Feedback_ID (like FB00003)
        $last_id_query = mysqli_query($con, "SELECT Feedback_ID FROM FactFeedback_Table ORDER BY Feedback_ID DESC LIMIT 1");
        if ($last_row = mysqli_fetch_assoc($last_id_query)) {
            $last_num = (int)substr($last_row['Feedback_ID'], 2); // remove 'FB'
            $new_num = $last_num + 1;
        } else {
            $new_num = 1;
        }
        $feedback_id = 'FB' . str_pad($new_num, 5, '0', STR_PAD_LEFT);
        if($field == "Response_Value") {
            mysqli_query($con, "INSERT INTO FactFeedback_Table (Feedback_ID, Student_ID, Type_ID, Question_ID, Q, Response_Value, Counter) VALUES ('$feedback_id', '$stud_id', '$type_id', '$question_id', '$q', '$value', 1)");
        }
        else {
            mysqli_query($con, "INSERT INTO FactFeedback_Table (Feedback_ID, Student_ID, Type_ID, Question_ID, Q, Counter) VALUES ('$feedback_id', '$stud_id', '$type_id', '$question_id', '$q', '$value')");
        }
    }
}
?>

MMCT - 2023