Question:
My Replit webserver doesn’t seem to be processing PHP correctly.
I have a simple checkbox (code below) that when I select a value, then submit, the results always indicate that nothing was selected…
Side note: process.php keeps spawning. - Not sure why…
Screenshots, links, or other helpful context:
Index.html
<!DOCTYPE html>
<html>
<head>
<title>Checkbox Form</title>
</head>
<body>
<form action="processs_checkboxes.php" method="post">
<input type="checkbox" name="hobbies[]" value="Reading"> Reading<br>
<input type="checkbox" name="hobbies[]" value="Swimming"> Swimming<br>
<input type="checkbox" name="hobbies[]" value="Coding"> Coding<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
processs_checkboxes.php
<?php
// Debugging: Dump all POST data
var_dump($_POST);
// Check if the "hobbies" array exists
if (isset($_POST['hobbies'])) {
$hobbies = $_POST['hobbies'];
// Loop through the array to read individual hobbies
echo "You have selected the following hobbies: <br>";
foreach ($hobbies as $hobby) {
echo $hobby . "<br>";
}
} else {
echo "No hobbies selected.";
}
?>