Please add at least one question.'; } else { $form_id = uniqid('form_'); $admin_token = bin2hex(random_bytes(16)); $form_data = [ 'id' => $form_id, 'title' => $title, 'description' => $description, 'admin_email' => $admin_email, 'admin_token' => $admin_token, 'created_at' => date('c'), 'questions' => $questions ]; $forms_dir = __DIR__ . '/data/forms'; if (!is_dir($forms_dir)) { mkdir($forms_dir, 0755, true); } file_put_contents("$forms_dir/$form_id.json", json_encode($form_data, JSON_PRETTY_PRINT)); $protocol = (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] !== 'off' || $_SERVER['SERVER_PORT'] == 443) ? "https://" : "http://"; $host = $_SERVER['HTTP_HOST']; $base_url = $protocol . $host . dirname($_SERVER['REQUEST_URI']); if (substr($base_url, -1) !== '/') { $base_url .= '/'; } $answer_link = $base_url . "answer.php?id=" . $form_id; $admin_link = $base_url . "admin.php?id=" . $form_id . "&token=" . $admin_token; $output_links = [ 'answer' => $answer_link, 'admin' => $admin_link ]; // Send email if provided if (!empty($admin_email) && filter_var($admin_email, FILTER_VALIDATE_EMAIL)) { $subject = "Your Intranet Form is Ready: $title"; $email_body = "Hello,\n\nYour form '$title' has been created.\n\n"; $email_body .= "Public Link for respondents:\n$answer_link\n\n"; $email_body .= "Secret Admin Link for you to view responses:\n$admin_link\n\n"; $email_body .= "Do not share the admin link.\n\nThank you."; $headers = "From: no-reply@" . $host . "\r\n"; @mail($admin_email, $subject, $email_body, $headers); } $form_created = true; } } ?> Create Form

Form Created Successfully!

Public Answering Link (Share this):
Secret Admin Link (Keep this safe):

A notification with these links has been sent to

Form Settings

Questions

No questions added yet. Use the buttons above to add one.
Cancel