connect_error) { die("Connection failed: " . $db->connect_error); } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $title = $db->real_escape_string($_POST['title']); $welcome_content = $db->real_escape_string($_POST['welcome_content']); $unique_id = uniqid(); $db->query("INSERT INTO surveys (title, welcome_content, unique_id) VALUES ('$title', '$welcome_content', '$unique_id')"); $survey_id = $db->insert_id; foreach ($_POST['pages'] as $page_number => $page_data) { $question_text = $db->real_escape_string($page_data['question']); $db->query("INSERT INTO pages (survey_id, page_number, question_text) VALUES ($survey_id, $page_number, '$question_text')"); $page_id = $db->insert_id; foreach ($page_data['choices'] as $index => $choice_text) { $choice_text = $db->real_escape_string($choice_text); $redirect_url = $db->real_escape_string($page_data['redirects'][$index] ?? ''); $db->query("INSERT INTO choices (page_id, choice_text, redirect_url) VALUES ($page_id, '$choice_text', " . ($redirect_url ? "'$redirect_url'" : "NULL") . ")"); } } $_SESSION['message'] = "Survey created successfully!"; $_SESSION['message_type'] = "success"; header("Location: index.php"); exit; } ?> Create Dynamic Survey

Create Dynamic Survey

Back to Main Page

Page 1 (Welcome Page)

This is your welcome page. No question needed here.