submit-questions.php (839B)
1 <?php 2 include_once 'session.php'; 3 include_once '../config.php'; 4 5 $questions = array(); 6 $survey_id = $_SESSION['sid']; 7 $questions = $_POST['questions']; 8 9 for($counter = 0; $counter < sizeof($questions); $counter++) 10 { 11 $q = $questions[$counter]; 12 13 if (empty($q)) { 14 header("Location: ../questions.php?err=notcomplete"); 15 exit(); 16 } 17 } 18 19 for($counter = 0; $counter < sizeof($questions); $counter++){ 20 $q = mysqli_real_escape_string($connect, $questions[$counter]); 21 echo "Question #".($counter + 1).": ".$questions[$counter]."<br />"; 22 $sql = "INSERT INTO question (survey_id, question_number, question_content) 23 VALUES ('$survey_id', $counter + 1, '$q');"; 24 mysqli_query($connect, $sql) or die(mysqli_error($connect)); 25 } 26 27 28 unset($_SESSION["questions"]); 29 header("Location: ../success.php"); 30 exit(); 31 ?>