survey system software
This commit is contained in:
parent
492966ea9e
commit
98a3b2866e
83
assets/css/custom.css
Normal file
83
assets/css/custom.css
Normal file
@ -0,0 +1,83 @@
|
|||||||
|
/* General Body Styles */
|
||||||
|
body {
|
||||||
|
background-color: #F3F4F6;
|
||||||
|
font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
|
||||||
|
color: #1F2937;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Main Container */
|
||||||
|
.container {
|
||||||
|
max-width: 800px;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Survey Card */
|
||||||
|
.card {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border: none;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-header {
|
||||||
|
background-color: #FFFFFF;
|
||||||
|
border-bottom: 1px solid #E5E7EB;
|
||||||
|
padding: 1.5rem;
|
||||||
|
border-top-left-radius: 0.5rem;
|
||||||
|
border-top-right-radius: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-title {
|
||||||
|
color: #1F2937;
|
||||||
|
font-weight: 600;
|
||||||
|
}
|
||||||
|
|
||||||
|
.card-body {
|
||||||
|
padding: 1.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Form Elements */
|
||||||
|
.form-label {
|
||||||
|
font-weight: 500;
|
||||||
|
margin-bottom: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control, .form-check-input {
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
border: 1px solid #D1D5DB;
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-control:focus, .form-check-input:focus {
|
||||||
|
border-color: #2563EB;
|
||||||
|
box-shadow: 0 0 0 0.25rem rgb(37 99 235 / 25%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.form-check-label {
|
||||||
|
margin-left: 0.5rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Buttons */
|
||||||
|
.btn-primary {
|
||||||
|
background-color: #2563EB;
|
||||||
|
border-color: #2563EB;
|
||||||
|
border-radius: 0.5rem;
|
||||||
|
padding: 0.75rem 1.5rem;
|
||||||
|
font-weight: 500;
|
||||||
|
transition: background-color 0.2s ease-in-out;
|
||||||
|
}
|
||||||
|
|
||||||
|
.btn-primary:hover {
|
||||||
|
background-color: #1D4ED8;
|
||||||
|
border-color: #1D4ED8;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Thank You Page */
|
||||||
|
.thank-you-container {
|
||||||
|
text-align: center;
|
||||||
|
padding: 3rem;
|
||||||
|
}
|
||||||
|
|
||||||
|
.thank-you-icon {
|
||||||
|
color: #14B8A6;
|
||||||
|
font-size: 4rem;
|
||||||
|
margin-bottom: 1rem;
|
||||||
|
}
|
||||||
@ -15,3 +15,29 @@ function db() {
|
|||||||
}
|
}
|
||||||
return $pdo;
|
return $pdo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function run_migrations() {
|
||||||
|
$pdo = db();
|
||||||
|
try {
|
||||||
|
$pdo->query("CREATE TABLE IF NOT EXISTS migrations (migration VARCHAR(255) PRIMARY KEY, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP)");
|
||||||
|
|
||||||
|
$result = $pdo->query("SELECT migration FROM migrations");
|
||||||
|
$run_migrations = $result->fetchAll(PDO::FETCH_COLUMN);
|
||||||
|
|
||||||
|
$migration_files = glob(__DIR__ . '/migrations/*.sql');
|
||||||
|
foreach ($migration_files as $file) {
|
||||||
|
$migration_name = basename($file);
|
||||||
|
if (!in_array($migration_name, $run_migrations)) {
|
||||||
|
$sql = file_get_contents($file);
|
||||||
|
$pdo->exec($sql);
|
||||||
|
$stmt = $pdo->prepare("INSERT INTO migrations (migration) VALUES (?)");
|
||||||
|
$stmt->execute([$migration_name]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
error_log('Migration failed: ' . $e->getMessage());
|
||||||
|
// In a production environment, you might want to die() here.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
run_migrations();
|
||||||
|
|||||||
9
db/migrations/001_create_responses_table.sql
Normal file
9
db/migrations/001_create_responses_table.sql
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
CREATE TABLE IF NOT EXISTS survey_responses (
|
||||||
|
id INT AUTO_INCREMENT PRIMARY KEY,
|
||||||
|
survey_id INT NOT NULL,
|
||||||
|
respondent_email VARCHAR(255),
|
||||||
|
question_1_answer TEXT,
|
||||||
|
question_2_answer TEXT,
|
||||||
|
question_3_answer TEXT,
|
||||||
|
submitted_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
|
||||||
|
);
|
||||||
11
index.php
11
index.php
@ -134,7 +134,16 @@ $projectImageUrl = $_SERVER['PROJECT_IMAGE_URL'] ?? '';
|
|||||||
<body>
|
<body>
|
||||||
<main>
|
<main>
|
||||||
<div class="card">
|
<div class="card">
|
||||||
<h1>Analyzing your requirements and generating your website…</h1>
|
<div class="text-center">
|
||||||
|
<h1 class="display-5 fw-bold">Welcome to Your Survey Management System</h1>
|
||||||
|
<div class="col-lg-6 mx-auto">
|
||||||
|
<p class="lead mb-4">Ready to gather insights? Create, share, and analyze surveys with ease. Get started by taking our sample survey.</p>
|
||||||
|
<div class="d-grid gap-2 d-sm-flex justify-content-sm-center">
|
||||||
|
<a href="survey.php" class="btn btn-primary btn-lg px-4 gap-3">Take the Sample Survey</a>
|
||||||
|
<button type="button" class="btn btn-outline-secondary btn-lg px-4">Learn More</button>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
<div class="loader" role="status" aria-live="polite" aria-label="Applying initial changes">
|
||||||
<span class="sr-only">Loading…</span>
|
<span class="sr-only">Loading…</span>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
45
submit_survey.php
Normal file
45
submit_survey.php
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
<?php
|
||||||
|
session_start();
|
||||||
|
require_once 'db/config.php';
|
||||||
|
|
||||||
|
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
|
||||||
|
header('Location: index.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Basic server-side validation
|
||||||
|
$survey_id = filter_input(INPUT_POST, 'survey_id', FILTER_VALIDATE_INT);
|
||||||
|
$email = filter_input(INPUT_POST, 'respondent_email', FILTER_VALIDATE_EMAIL);
|
||||||
|
$satisfaction = filter_input(INPUT_POST, 'satisfaction', FILTER_SANITIZE_STRING);
|
||||||
|
$features = isset($_POST['features']) ? $_POST['features'] : [];
|
||||||
|
|
||||||
|
if (!$survey_id || !$email || !$satisfaction) {
|
||||||
|
$_SESSION['error_message'] = 'Please fill out all required fields.';
|
||||||
|
header('Location: survey.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Combine checkbox answers into a single string
|
||||||
|
$features_str = is_array($features) ? implode(', ', $features) : '';
|
||||||
|
|
||||||
|
try {
|
||||||
|
$pdo = db();
|
||||||
|
$sql = "INSERT INTO survey_responses (survey_id, respondent_email, question_1_answer, question_2_answer) VALUES (?, ?, ?, ?)";
|
||||||
|
$stmt = $pdo->prepare($sql);
|
||||||
|
|
||||||
|
if ($stmt->execute([$survey_id, $email, $satisfaction, $features_str])) {
|
||||||
|
$_SESSION['success_message'] = 'Thank you for your submission!';
|
||||||
|
header('Location: thank_you.php');
|
||||||
|
exit;
|
||||||
|
} else {
|
||||||
|
$_SESSION['error_message'] = 'There was an error saving your response. Please try again.';
|
||||||
|
header('Location: survey.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
|
} catch (PDOException $e) {
|
||||||
|
// In a real app, you would log this error, not show it to the user.
|
||||||
|
error_log('Database Error: ' . $e->getMessage());
|
||||||
|
$_SESSION['error_message'] = 'A database error occurred. Please try again later.';
|
||||||
|
header('Location: survey.php');
|
||||||
|
exit;
|
||||||
|
}
|
||||||
82
survey.php
Normal file
82
survey.php
Normal file
@ -0,0 +1,82 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Customer Feedback Survey - Create a survey management system</title>
|
||||||
|
<meta name="description" content="Provide your feedback to help us improve our services. Built with Flatlogic Generator.">
|
||||||
|
<meta name="keywords" content="survey, feedback, customer satisfaction, product review, service quality, survey management system, Built with Flatlogic Generator">
|
||||||
|
<meta property="og:title" content="Customer Feedback Survey - Create a survey management system">
|
||||||
|
<meta property="og:description" content="Provide your feedback to help us improve our services. Built with Flatlogic Generator.">
|
||||||
|
<meta property="og:image" content="">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:image" content="">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container my-5">
|
||||||
|
<div class="card">
|
||||||
|
<div class="card-header">
|
||||||
|
<h1 class="card-title h4">Customer Feedback Survey</h1>
|
||||||
|
<p class="text-muted mb-0">Thank you for taking the time to provide your valuable feedback.</p>
|
||||||
|
</div>
|
||||||
|
<div class="card-body">
|
||||||
|
<form action="submit_survey.php" method="POST">
|
||||||
|
<input type="hidden" name="survey_id" value="1">
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label for="email" class="form-label">What is your email address?</label>
|
||||||
|
<input type="email" class="form-control" id="email" name="respondent_email" required>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label">How satisfied are you with our product?</label>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="satisfaction" id="very_satisfied" value="Very Satisfied" required>
|
||||||
|
<label class="form-check-label" for="very_satisfied">Very Satisfied</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="satisfaction" id="satisfied" value="Satisfied">
|
||||||
|
<label class="form-check-label" for="satisfied">Satisfied</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="satisfaction" id="neutral" value="Neutral">
|
||||||
|
<label class="form-check-label" for="neutral">Neutral</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="radio" name="satisfaction" id="dissatisfied" value="Dissatisfied">
|
||||||
|
<label class="form-check-label" for="dissatisfied">Dissatisfied</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="mb-4">
|
||||||
|
<label class="form-label">Which features do you use the most? (Select all that apply)</label>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="features[]" value="Feature A" id="feature_a">
|
||||||
|
<label class="form-check-label" for="feature_a">Feature A</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="features[]" value="Feature B" id="feature_b">
|
||||||
|
<label class="form-check-label" for="feature_b">Feature B</label>
|
||||||
|
</div>
|
||||||
|
<div class="form-check">
|
||||||
|
<input class="form-check-input" type="checkbox" name="features[]" value="Feature C" id="feature_c">
|
||||||
|
<label class="form-check-label" for="feature_c">Feature C</label>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" class="btn btn-primary w-100">Submit Feedback</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
42
thank_you.php
Normal file
42
thank_you.php
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
<?php session_start(); ?>
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<title>Thank You! - Create a survey management system</title>
|
||||||
|
<meta name="description" content="Thank you for your feedback. Built with Flatlogic Generator.">
|
||||||
|
<meta name="keywords" content="thank you, confirmation, survey complete, feedback received, survey management system, Built with Flatlogic Generator">
|
||||||
|
<meta property="og:title" content="Thank You! - Create a survey management system">
|
||||||
|
<meta property="og:description" content="Thank you for your feedback. Built with Flatlogic Generator.">
|
||||||
|
<meta property="og:image" content="">
|
||||||
|
<meta name="twitter:card" content="summary_large_image">
|
||||||
|
<meta name="twitter:image" content="">
|
||||||
|
<meta name="robots" content="noindex, nofollow">
|
||||||
|
|
||||||
|
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
|
||||||
|
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||||
|
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
||||||
|
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600&display=swap" rel="stylesheet">
|
||||||
|
<link rel="stylesheet" href="assets/css/custom.css?v=<?php echo time(); ?>">
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div class="container my-5">
|
||||||
|
<div class="card thank-you-container">
|
||||||
|
<div class="card-body">
|
||||||
|
<i class="bi bi-check-circle-fill thank-you-icon"></i>
|
||||||
|
<h1 class="card-title h2">Thank You!</h1>
|
||||||
|
<?php if (isset($_SESSION['success_message'])): ?>
|
||||||
|
<p class="lead"><?php echo htmlspecialchars($_SESSION['success_message']); unset($_SESSION['success_message']); ?></p>
|
||||||
|
<?php else: ?>
|
||||||
|
<p class="lead">Your submission has been received.</p>
|
||||||
|
<?php endif; ?>
|
||||||
|
<a href="index.php" class="btn btn-light mt-3">Back to Home</a>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
Loading…
x
Reference in New Issue
Block a user