<?php require_once "../includes/db_connect.php"; require_once "../includes/functions.php"; require_once "../includes/session.php"; require_once "utils/question.php"; require_once "utils/user.php"; confirm_logged_in(); if (isset($_POST["submit"])) { $db = new DB_CONNECT(); // get username from the session $username = get_username(); if (check_is_set($_POST)) { if (check_empty($_POST)) { $test_name = $db->mysql_prep($_POST["test_name"]); $start_time = make_sql_date_time($_POST["start_time"], "/"); $end_time = make_sql_date_time($_POST["end_time"], "/"); $event_date = $db->mysql_prep($_POST["event_date"]); $duration = $db->mysql_prep($_POST["duration"]); $query = "UPDATE test SET test_name='{$test_name}', username='******',start_time='{$start_time}',\n end_time='{$end_time}',event_date='{$event_date}',duration='{$duration}' WHERE test_name='{$test_name}' "; $result = $db->query_database($query); if (is_null($result)) { // query failed echo "query failed"; } else { redirect_to("question_list.php?test_name=" . get_test_name()); } } else { echo "empty fields"; } } else {
<?php require_once "../includes/db_connect.php"; require_once "../includes/functions.php"; require_once "../includes/session.php"; confirm_logged_in(); if (isset($_POST["submit"])) { $question_id = $_POST['question_id']; $decode_url = $_POST['test_name']; $keys = array("question", "option1", "option2", "option3", "option4", "radio", "marks", "negative_marks"); if (!array_diff($keys, array_keys($_POST)) && check_is_set($_POST)) { $table_name = $decode_url . "_questions"; $table_data = array(); $table_data["question_id"] = $db->mysql_prep($_POST["question_id"]); $table_data["question"] = $db->mysql_prep($_POST["question"]); $table_data["option1"] = $db->mysql_prep($_POST["option1"]); $table_data["option2"] = $db->mysql_prep($_POST["option2"]); $table_data["option3"] = $db->mysql_prep($_POST["option3"]); $table_data["option4"] = $db->mysql_prep($_POST["option4"]); $table_data["correct_ans"] = $db->mysql_prep($_POST["radio"]); $table_data["marks"] = $db->mysql_prep($_POST["marks"]); $table_data["negative_marks"] = $db->mysql_prep($_POST["negative_marks"]); $query = "UPDATE " . $table_name . " SET question='{$table_data["question"]}'\n ,option1='{$table_data["option1"]}',option2='{$table_data["option2"]}',\n option3='{$table_data["option3"]}',option4='{$table_data["option4"]}',\n correct_ans='{$table_data["correct_ans"]}',marks='{$table_data["marks"]}',\n negative_marks='{$table_data["negative_marks"]}' WHERE id={$table_data["question_id"]} "; $update_query_result = $db->query_database($query); if ($update_query_result != NULL) { redirect_to("question_list.php?test_name={$decode_url}"); } } } else { $question_id = urldecode($_GET['question_id']); $decode_url = urldecode($_GET['test_name']);