/** Laita kysymys tietokantaan * @param $question_id integer */ function put_question_to_db($question_id) { /* $title string * $body string * $tags string */ if (check_user_status()) { echo "User status pelaa"; $body = pg_escape_string($_POST['question']['body']); $title = pg_escape_string($_POST['question']['title']); $tags = $_POST['question']['tags']; if (validate_input($title, $body, $tags)) { echo "User input pelaa"; $title = $_POST['question']['title']; set_question($question_id); set_tags($question_id); header("Location: /pgCodesS/index.php?" . "question_updated" . "&" . "question_id=" . $question_id . "&" . $title); } else { header("Location: /pgCodesS/index.php?" . "&unsuccessful_new_question"); } } else { header("Location: /pgCodesS/index.php" . "&unsuccessful_new_question"); } }
/** * Ota uusi kysymys tietokantaan */ function receive_new_question() { /* $question_id integer * $title string * $body string * $tags string */ $body = pg_escape_string($_POST['question']['body']); $title = pg_escape_string($_POST['question']['title']); $tags = $_POST['question']['tags']; /** * Tarkasta sisaankirjaus */ if (check_user_status()) { echo "User status pelaa"; if (validate_input($title, $body, $tags)) { echo "User input pelaa"; $title = $_POST['question']['title']; set_question(); set_tags(); $question_id = get_question_id(); // question must be set before header("Location: /pgCodesS/index.php?" . "question_sent" . "&" . "question_id=" . $question_id . "&" . $title); } else { header("Location: /pgCodesS/index.php?" . "ask_question" . "&unsuccessful_new_question"); } } else { header("Location: /pgCodesS/index.php" . "ask_question" . "&unsuccessful_new_question"); } }