function doAction($action) { $forwardpage = ""; $forward = true; $loggedin = isUserLoggedIn(); if (!$loggedin && strcmp($action, "login") != 0 && strcmp($action, "register") != 0 && strcmp($action, "getTags") != 0) { addError("fatal", "user.unathorized"); outputJSON("error"); } else { if (strcmp($action, "login") == 0) { login(); } else { if (strcmp($action, "logout") == 0) { logout(); } else { if (strcmp($action, "isLoggedIn") == 0) { isLoggedIn(); } else { if (strcmp($action, "register") == 0) { register(); } else { if (strcmp($action, "addquestion") == 0) { addQuestion(); } else { if (strcmp($action, "getTags") == 0) { getTags(); } else { if (strcmp($action, "getquestions") == 0) { getQuestions(); } } } } } } } } }
echo 1; return; } // foreach($correct as $i): // if($correct[$i] == ""){ // echo 1; // return; // } // endforeach; // foreach($options as $i): // if($options[$i] == ""){ // echo 1; // return; // } // endforeach; $d = addQuestion($topic_ID, $diff, $isMultiple, $quest, $correct, $options); echo $d; } //Insert question if a request has been made if (isset($_POST['editQ'])) { //1 = fill out the form //GET POST VARS $qID = $_POST['qID']; $quest = $_POST['quest']; $diff = $_POST['diff']; $isMultiple = $_POST['isMultiple']; $correct = json_decode($_POST['correct']); $options = json_decode($_POST['options']); // print_r_nice($options); //Validate that everything has been filled in and not left empty for ($i = 0; $i < sizeof($correct); $i++) {
chat(); break; case 'dateRequest': dateRequest(); break; case 'loadMessage': loadMessage(); break; case 'loadMessageByUser': loadMessageByUser(); break; case 'shout': shout(); break; case 'addQuestion': addQuestion(); break; case 'addAnswer': addAnswer(); break; case 'addShop': addShop(); break; case 'idUpload': idUpload(); break; case 'updateForm': updateForm(); break; case 'updateUserImage': updateUserImage();
<html> <?php include 'header.php'; ?> <body> <?php include 'functions.php'; ?> <?php include 'connectdb.php'; ?> <?php //Getting data from the former page via POST method $id = $_POST["id"]; $question = $_POST["question"]; $answer = $_POST["answer"]; addQuestion($id, $question); addAnswers($answer); //Redirect to event page header("Location: event-settings.php?id=" . $id); ?> </body> </html>
if ($dbf->query("INSERT INTO cn_tags (value) VALUES ('{$value}')")) { return $dbf->last_id(); } else { return false; } } function insertTagAssociation($questionID, $tagID, $userID) { global $dbf; $query = "INSERT INTO cn_idx_tags_questions (fk_question_id, fk_tag_id, fk_user_id) "; $query .= "VALUES ({$questionID}, {$tagID}, {$userID})"; $dbf->query($query); } if (isset($_POST['submitted'])) { if (!empty($_POST['question']) && $_POST['event'] != '0') { addQuestion($_POST['event'], $userID, $_POST['question'], $_POST['desc'], $_POST['tags']); } } /* end logic */ echo ' <div align="center"> <form method="post" action="' . $_SERVER['PHP_SELF'] . '"> <h3>Event</h3> <select name="event"> <option value="0"></option>' . populateEventsSelect($events) . '</select> <h3>Question</h3> Enter a question you would like asked.<br/> <input type="text" name="question" maxlength="100"/> <h3>Description</h3> Write a brief description explaining your quesiton (limit 250 chars).<br/> <textarea rows="2" cols="20" name="desc">y helo thar</textarea>
<?php include 'sendFunctions.php'; $action_to_execute = $_GET['action']; switch ($action_to_execute) { case "addQuestion": echo addQuestion($_GET['question_to_add'], $_GET['question_body']); //echo true or false to see if it worked or not break; case "addUser": echo addUser($_GET['user_to_add'], $_GET['password'], $_GET['email']); break; //so on and so forth }
} else { unset($_POST['questionErrors']); if (isset($_GET['questionid'])) { $questionID = $_GET['questionid']; dbQuery("update quiz_questions \n\t\t\t\tset \n\t\t\t\tquestion = '{$question}', \n\t\t\t\ttopic = '{$topic}', \n\t\t\t\tanswer1 = '{$answers['0']}', \n\t\t\t\tanswer2 = '{$answers['1']}', \n\t\t\t\tanswer3 = '{$answers['2']}', \n\t\t\t\tanswer4 = '{$answers['3']}', \n\t\t\t\tcorrectAnswer = '{$correctAnswer}' \n\t\t\t\twhere id = '{$questionID}'"); } else { dbQuery("INSERT INTO quiz_questions(\n\t\t\t\t\tquiz_id, \n\t\t\t\t\tquestion, \n\t\t\t\t\ttopic, \n\t\t\t\t\tanswer1,\n\t\t\t\t\tanswer2, \n\t\t\t\t\tanswer3, \n\t\t\t\t\tanswer4, \n\t\t\t\t\tcorrectAnswer\n\t\t\t\t)\n\t\t\t\tVALUES(\n\t\t\t\t\t'{$id}', \n\t\t\t\t\t'{$question}', \n\t\t\t\t\t'{$topic}', \n\t\t\t\t\t'{$answers['0']}',\n\t\t\t\t\t'{$answers['1']}', \n\t\t\t\t\t'{$answers['2']}', \n\t\t\t\t\t'{$answers['3']}', \n\t\t\t\t\t'{$correctAnswer}'\n\t\t\t\t)"); } } } } } echo '</div>'; //Ends the tabs div if (strcmp($action, 'editQuestion') == 0 || strcmp($action, 'newQuestion') == 0) { $addString = addQuestion(); echo '<script>'; echo '$("#Questions").append(' . json_encode($addString) . ');'; echo '</script>'; } // } echo '</form>'; // } /** * This checks that a selection was made for the correct answer * and that the selected answer is not null * * @param array $array The answers * @param bool $correctAnswer The index of the correct answer * * @return bool
<?php include 'DBO.php'; $connection = connectToDatabase(); $examId = $_GET['examId']; $questionId = $_GET['questionId']; $questionText = $_GET['questionText']; $correctAnswer = $_GET['correctAnswer']; $result = addQuestion($connection, $examId, $questionId, $questionText, $correctAnswer); echo json_encode($result);
<!--@author : Ignatius Alriana H.M / 13513051--> <html> <head> <title>Submit Question - Simple StackExchange</title> <link rel="stylesheet" type="text/css" href="SiteStyle.css"> </head> <body> <?php include 'dbact.php'; if (!(isset($_POST['id_q']) && isset($_POST['Name']) && isset($_POST['Email']) && isset($_POST['Topic']) && isset($_POST['Content']))) { echo '<h2>Error</h2>'; header("Location: ask.php"); exit; } if ($_POST['id_q'] == '') { $id = addQuestion($_POST['Name'], $_POST['Email'], $_POST['Topic'], $_POST['Content']); $q = getLastQid(); $id_q = $q['id_q']; } else { $id = updateQuestion($_POST['id_q'], $_POST['Name'], $_POST['Email'], $_POST['Topic'], $_POST['Content']); $id_q = $_POST['id_q']; } $id_q = trim($id_q); echo $id_q; header("Location: displayQuestion.php?id_q=+" . basename($id_q) . ""); /* Redirect browser */ ?> </body> </html>