To execute the web form survey, follow these steps:
1. Set Up a Local Development Environment
If you don’t have a web server or hosting yet, you can set up a local development environment
on your computer to test the survey.
Option 1: Using XAMPP (for PHP-based forms)
XAMPP is a free and open-source cross-platform web server solution stack package, which
includes Apache, MySQL, PHP, and Perl.
Steps to install and set up XAMPP:
1. Download and Install XAMPP:
o Go to XAMPP's official site and download the version for your operating system.
o Install it and launch the XAMPP Control Panel.
2. Start the Apache Server:
o Open XAMPP Control Panel and click "Start" next to Apache to start the web
server.
3. Create a Project Folder:
o Navigate to the htdocs folder inside your XAMPP installation directory (usually
C:\xampp\htdocs on Windows).
o Create a folder for your project, e.g., survey_form.
4. Create the HTML and PHP Files:
o Inside the survey_form folder, create two files:
index.html: This will contain your HTML survey form.
submit-survey.php: This will handle the form submission.
5. Paste the Code:
o index.html:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Student Survey</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 20px;
background-color: #f4f4f4;
.survey-form {
background-color: white;
padding: 20px;
border-radius: 5px;
max-width: 600px;
margin: auto;
box-shadow: 0px 0px 10px rgba(0,0,0,0.1);
.survey-form h2 {
text-align: center;
margin-bottom: 20px;
.form-group {
margin-bottom: 15px;
.form-group label {
display: block;
margin-bottom: 5px;
.form-group input, .form-group select, .form-group textarea {
width: 100%;
padding: 10px;
border: 1px solid #ccc;
border-radius: 5px;
.form-group input[type="radio"], .form-group input[type="checkbox"] {
width: auto;
.form-group button {
width: 100%;
padding: 10px;
background-color: #28a745;
border: none;
color: white;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
.form-group button:hover {
background-color: #218838;
</style>
</head>
<body>
<div class="survey-form">
<h2>Student Survey Form</h2>
<form action="submit-survey.php" method="POST">
<div class="form-group">
<label for="name">Name:</label>
<input type="text" id="name" name="name" placeholder="Your name" required>
</div>
<div class="form-group">
<label for="age">Age:</label>
<select id="age" name="age" required>
<option value="">Select your age</option>
<option value="13-14">13-14</option>
<option value="15-16">15-16</option>
<option value="17-18">17-18</option>
</select>
</div>
<div class="form-group">
<label for="activities">Which extracurricular activities do you participate in?</label>
<input type="checkbox" id="sports" name="activities[]" value="Sports"> Sports<br>
<input type="checkbox" id="music" name="activities[]" value="Music"> Music<br>
<input type="checkbox" id="arts" name="activities[]" value="Arts"> Arts<br>
<input type="checkbox" id="tech" name="activities[]" value="Tech"> Tech Club<br>
<input type="checkbox" id="other" name="activities[]" value="Other"> Other
</div>
<div class="form-group">
<label>How satisfied are you with the available options?</label>
<input type="radio" id="very-satisfied" name="satisfaction" value="Very Satisfied" required>
Very Satisfied<br>
<input type="radio" id="satisfied" name="satisfaction" value="Satisfied"> Satisfied<br>
<input type="radio" id="neutral" name="satisfaction" value="Neutral"> Neutral<br>
<input type="radio" id="unsatisfied" name="satisfaction" value="Unsatisfied"> Unsatisfied<br>
<input type="radio" id="very-unsatisfied" name="satisfaction" value="Very Unsatisfied"> Very
Unsatisfied
</div>
<div class="form-group">
<label for="feedback">What activities would you like to see added?</label>
<textarea id="feedback" name="feedback" rows="4" placeholder="Your
suggestions"></textarea>
</div>
<div class="form-group">
<button type="submit">Submit Survey</button>
</div>
</form>
</div>
</body>
</html>
submit-survey.php:
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = $_POST['name'];
$age = $_POST['age'];
$activities = isset($_POST['activities']) ? implode(", ", $_POST['activities']) : 'None';
$satisfaction = $_POST['satisfaction'];
$feedback = $_POST['feedback'];
// Save the data to a file
$file = fopen("survey_responses.txt", "a");
fwrite($file, "Name: $name\nAge: $age\nActivities: $activities\nSatisfaction: $satisfaction\nFeedback:
$feedback\n\n");
fclose($file);
echo "Thank you for submitting the survey!";
?>
Run the Project:
Open your browser and type http://localhost/survey_form/index.html in the
address bar.
Fill out the form and submit it.
After submitting, the PHP script will process the data and save it to a text file
(survey_responses.txt) located in the same folder.