<!--@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['Content']))) {
    echo '<h2>Error</h2>';
    if (isset($_SERVER["HTTP_REFERER"])) {
        header("Location: " . $_SERVER["HTTP_REFERER"]);
    }
    exit;
}
$id = addAnswer($_POST['id_q'], $_POST['Name'], $_POST['Email'], $_POST['Content']);
echo "Berhasil oom";
header("Location: " . $_SERVER["HTTP_REFERER"]);
/* Redirect browser */
?>
	</body>
</html>
Exemple #2
0
     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();
     break;
 default:
     login();
            $quesName = $row['adescription'];
            $quesNameShrt = $quesName;
            $quesId = $row['aid'];
            $ansId = $row['ansId'];
            //echo "have question###-------- ".$quesId." -----ANSWER ID--------- ".$ansId."<br>";
            $quesNameShrt = str_replace(' ', '', $quesNameShrt);
            $value = $_POST["{$quesId}"];
            $value = str_replace('a', '', $value);
            //echo "the value:".$value."<br />";
            //prevent repeating and diffferent data being fed
            if ($quesIdCheck != $quesId) {
                $quesIdCheck = $quesId;
                $noRepeat = false;
            }
            if ($value != '0' && $noRepeat == false) {
                addAnswer($quesId, $value, $uvid);
                $noRepeat = true;
            }
            //$quesIdCheck = $quesId;
            if ($value == '0') {
                //echo "----------------didn't answer question------------------";
                $returnIndex = false;
            }
            // function to do work
        }
    }
}
if ($returnIndex == true) {
    echo "<script>window.location.href = \"index.php\";</script>";
} else {
    //return to last User Survey(currently characterisitcs)
Exemple #4
0
         if ($res[0] == 1) {
             header("location:index.php");
         } else {
             exit($res[1]);
         }
     }
 } else {
     if ($ac == 'detail') {
         $qid = intval($_GET['id']);
         $qestion = getOneQuestion($qid);
         include 'tpl/detail.php';
     } else {
         if ($ac == 'doAnswer') {
             $qid = intval($_POST['qid']);
             $answer = trim($_POST['answer']);
             $qestion = addAnswer($qid, $answer);
             header("location:index.php?ac=detail&id=" . $qid);
         } else {
             if ($ac == 'doMessage') {
                 $messageAuthor = intval($_POST['messageAuthor']);
                 $content = trim($_POST['content']);
                 $message = addMessage($messageAuthor, $content);
                 header("location:index.php?ac=userinfo");
             } else {
                 if ($ac == 'search') {
                     $type = !empty($_GET['type']) ? intval($_GET['key']) : 1;
                     if ($type == 1) {
                         $key = !empty($_GET['key']) ? trim($_GET['key']) : null;
                         $memberid = !empty($_GET['memberid']) ? intval($_GET['memberid']) : null;
                         $title = $memberid ? '我的问题' : '';
                         $questions = getQuestionList($memberid, $key);
    return $data;
}
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    if ($_POST['type'] == 'question') {
        $question['name'] = test_input($_POST['name']);
        $question['email'] = test_input($_POST['email']);
        $question['topic'] = test_input($_POST['topic']);
        $question['content'] = test_input($_POST['content']);
        $question['q_id'] = $_POST['q_id'];
        updateQuestion($question);
    } else {
        $answer['q_id'] = $_GET['q_id'];
        $answer['name'] = test_input($_POST['name']);
        $answer['email'] = test_input($_POST['email']);
        $answer['content'] = test_input($_POST['content']);
        addAnswer($answer);
    }
}
?>

<?php 
$q_id = $_GET['q_id'];
$question = getQuestion($q_id);
$tabAnswer = getAnswers($q_id);
$nAnswer = mysqli_num_rows($tabAnswer);
?>
<div class="view">
  <h1>Simple Stack Exchange</h1><br>
  <h2 id="title"><?php 
echo $question['topic'];
?>
Exemple #6
0
/**
  * This shows the form to add a new question
  *
  * @return string The form to add a question
*/
function addQuestion()
{
    global $id;
    global $questionID;
    global $question;
    // { Question Tab
    $returnString = '<h2>';
    if (isset($_GET['questionid'])) {
        $questionID = addslashes($_GET['questionid']);
        $returnString = $returnString . 'Edit Question';
        $question = dbAll("select * from quiz_questions where id='{$questionID}'");
    } else {
        $returnString = $returnString . 'New Question';
    }
    $returnString = $returnString . '</h2>';
    $returnString = $returnString . '<input type="hidden" name="quiz_id" value="';
    $returnString = $returnString . htmlspecialchars($id) . '"/>';
    if (isset($questionID)) {
        $returnString = $returnString . '<input type="hidden"';
        $returnString = $returnString . 'name="question_id"';
        $returnString = $returnString . 'value="';
        $returnString = $returnString . htmlspecialchars($questionID) . '"';
        $returnString = $returnString . '"/>';
    }
    $returnString = $returnString . '<br/>';
    $returnString = $returnString . 'Question';
    $returnString = $returnString . pad();
    $returnString = $returnString . '<input type="text" name="question"';
    if (isset($_POST['question']) && isset($_POST['questionErrors'])) {
        $returnString = $returnString . 'value="';
        $returnString = $returnString . htmlspecialchars($_POST['question']) . '"';
    }
    if (isset($questionID)) {
        $returnString = $returnString . 'value="';
        foreach ($question as $q) {
            $returnString = $returnString . htmlspecialchars($q['question']) . '"';
        }
    }
    $returnString = $returnString . '/>';
    $returnString = $returnString . pad();
    $returnString = $returnString . 'Topic';
    $returnString = $returnString . '<input type="text" name="topic"';
    if (isset($_POST['topic']) && isset($_POST['questionErrors'])) {
        $returnString = $returnString . 'value="';
        $returnString = $returnString . htmlspecialchars($_POST['topic']) . '"';
    }
    if (isset($questionID)) {
        $returnString = $returnString . 'value="';
        foreach ($question as $q) {
            $returnString = $returnString . $q['topic'];
        }
        $returnString = $returnString . '"';
    }
    $returnString = $returnString . '/>';
    $returnString = $returnString . '</div>';
    // }
    // { Answers Tab
    $returnString = $returnString . '<h2>';
    if (isset($questionID)) {
        $returnString = $returnString . 'Edit Answers';
    } else {
        $returnString = $returnString . 'New Answers';
    }
    $returnString = $returnString . '</h2>';
    $returnString = $returnString . '<table>';
    $returnString = $returnString . '<thead>';
    $returnString = $returnString . '<tr>';
    $returnString = $returnString . '<th>';
    $returnString = $returnString . 'Possible Answers';
    $returnString = $returnString . '</th>';
    $returnString = $returnString . '<th>';
    $returnString = $returnString . 'Correct Answer';
    $returnString = $returnString . '</th>';
    $returnString = $returnString . '</tr>';
    $returnString = $returnString . '</thead>';
    $returnString = $returnString . '<tbody>';
    for ($i = 0; $i < '4'; $i++) {
        $num = $i + 1;
        $returnString = $returnString . '<tr>';
        $returnString = $returnString . addAnswer($num);
        $returnString = $returnString . '</tr>';
    }
    $returnString = $returnString . '</tbody>';
    $returnString = $returnString . '</table>';
    $returnString = $returnString . '</div>';
    // }
    $returnString = $returnString . '<input type="hidden" name="questionErrors">';
    $returnString = $returnString . '<input type="submit"';
    $returnString = $returnString . 'name="questionAction"';
    $returnString = $returnString . 'value="';
    if (isset($questionID)) {
        $returnString = $returnString . 'Edit';
    } else {
        $returnString = $returnString . 'Add';
    }
    $returnString = $returnString . ' Question"/>';
    $returnString = $returnString . '</div>';
    //Ends the tabs div*/
    return $returnString;
}
function addAnswers($answer)
{
    $questionId = getLastId();
    foreach ($answer as $a) {
        addAnswer($a, $questionId);
    }
}
<?php 
include_once 'database/polls_add.php';
include_once 'database/polls_fetch.php';
include 'templates/header.php';
include 'user.php';
$user = getUserIDbyUsername($_SESSION['username']);
$groupid = $_POST['groupid'];
//echo "$groupid";
$polls = getPollsFromGroup($groupid);
//echo '<br>'.count($polls).'<br>';
foreach ($polls as $poll) {
    if (isset($_POST[$poll['id']])) {
        //echo '<br>'.$_POST[$poll['id']].'<br>';
    } else {
        echo '<br>nao veio esta<br>';
        header("Location:polls_answer.php?err=notallanswered");
        exit;
    }
}
foreach ($polls as $poll) {
    $answer_title = $_POST[$poll['id']];
    $poll_id = $poll['id'];
    //echo "id"; echo $poll_id;
    $poll_option = getPollOption($poll_id, $answer_title)['id'];
    // echo "poll_option"; echo $poll_option;
    addAnswer($poll_id, $poll_option, $user);
    //echo 'fim';
}
header("Location:polls_answer.php");
include 'templates/footer.php';