Form Not Found

'); } $form_data = json_decode(file_get_contents($form_file), true); $questions_map = []; foreach ($form_data['questions'] as $q) { $questions_map[$q['id']] = $q['label']; } $injected_js = ''; if ($is_post) { // Process form submission $respondent_name = trim($_POST['respondent_name'] ?? 'Anonymous'); $respondent_email = trim($_POST['respondent_email'] ?? ''); $answers = $_POST['answers'] ?? []; $is_edit = !empty($answer_id); if (!$is_edit) { $answer_id = uniqid('ans_'); } $safe_answer_id = preg_replace('/[^a-zA-Z0-9_-]/', '', $answer_id); $answer_data = [ 'answer_id' => $safe_answer_id, 'form_id' => $form_id, 'respondent_name' => $respondent_name, 'respondent_email' => $respondent_email, 'submitted_at' => date('c'), 'answers' => $answers ]; file_put_contents("$answers_dir/{$form_id}_{$safe_answer_id}.json", json_encode($answer_data, JSON_PRETTY_PRINT)); // No longer injecting JS to prevent double-submit. $injected_js = ""; // Email notification if provided if (!empty($respondent_email) && filter_var($respondent_email, FILTER_VALIDATE_EMAIL)) { $subject = "Your submission for: " . $form_data['title']; $body = "Hi $respondent_name,\n\nThank you for your submission.\nHere is what you submitted:\n\n"; foreach ($answers as $q_id => $val) { $label = $questions_map[$q_id] ?? 'Question'; $val_str = is_array($val) ? implode(', ', $val) : $val; $body .= "$label:\n$val_str\n\n"; } $host = $_SERVER['HTTP_HOST']; $headers = "From: no-reply@" . $host . "\r\n"; @mail($respondent_email, $subject, $body, $headers); } // Redirect to self as GET to prevent duplicate POSTs on refresh header("Location: submit.php?id=" . urlencode($form_id) . "&answer_id=" . urlencode($safe_answer_id) . "&success=1"); exit; } // Display Mode (GET) $success = isset($_GET['success']); $safe_answer_id = preg_replace('/[^a-zA-Z0-9_-]/', '', $answer_id); $answer_file = "$answers_dir/{$form_id}_{$safe_answer_id}.json"; if (empty($safe_answer_id) || !file_exists($answer_file)) { die('

Submission Not Found

'); } $answer_data = json_decode(file_get_contents($answer_file), true); ?> Submission Complete
Your response has been successfully saved.
A copy of your responses was sent to .

Submitted Answers


$val): ?>
Edit Response