Using PHP from W3Schools as a refference, code the program below: Create an inde
ID: 3803650 • Letter: U
Question
Using PHP from W3Schools as a refference, code the program below:
Create an index.php with two datalists at the top of the page. The first datalist contains days of the week and the second datalist contains months of the year. Include navigation links on index.php to navigate to selfprocessor.php and validatecontrols.php (files used later) *Since this is only one question, I will later create these files but you could just create temp files*.
Enclose the two datalists in a form with:
a. action=“daymonth.php’
b. method=“get”
c. Submit button
Create a form processor file named daymonth.php that displays a welcome message and the day and month that was selected on index.php. Include a function called “validate _input” to ensure text data received from the form is safe before displaying the data. Include an HTML element of your choice to navigate back to index.php.
Create a second form with the following:
a. action=”favorites.php”
b. method=”post”
c. Name textbox (required – display appropriate error message next to the control)
d. Favorite Movie textbox (required – display appropriate error message next to the control)
e. Favorite Food textbox (required – display appropriate error message next to the control)
f. Four radio buttons for favorite season choices (make Summer the default setting)
g. Comments (optional)
h. Submit button
Thank you so much for yout time!!
Explanation / Answer
Find the below answers to the above question asked:
*****************************
Index.php
<!DOCTYPE HTML>
<html>
<head>
<style>
</style>
</head>
<body>
<form method="post" action="daymonth.php">
<input list="weeks" name="weeks" >
<datalist id="weeks">
<option value="sunday">
<option value="monday">
<option value="tuesday">
<option value="wednesday">
<option value="thursday">
<option value="friday">
</datalist>
<input list="Year" name="Year" >
<datalist id="Year">
<option value="Januaray">
<option value="Febraury">
<option value="March">
<option value="April">
<option value="May">
<option value="june">
<option value="july">
<option value="Augest">
<option value="September">
<option value="October">
<option value="November">
<option value="December">
</datalist>
<input type="submit" name="submit" value="Submit">
</form>
<?php
$_SESSION['weeks'] = $regValue;
$_SESSION['Year'] = $regValue1;
?>
</body>
</html>
*********************
daymonth.php
*******************
<!DOCTYPE html>
<html>
<body>
<?php
$regValue = $_SESSION['weeks'];
echo "Your week is: ".$regValue.".";
$regValue = $_SESSION['year'];
echo "Your year is: ".$regValue1.".";
?>
<script>
function validate _input(){
if($regValue&&$regValue!=null){
console.log('Input fields should not be empty');
}
}
<?php
header("Index.php");
exit; // <- don't forget this!
?>
</script>
</body>
</html>
*******************
Second form::
**********************
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<?php
// define variables and set to empty values
$name = $movie = $food = $season= "";
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$name = test_input($_POST["name"]);
$movie = test_input($_POST["movie"]);
$food = test_input($_POST["food"]);
$season = test_input($_POST["season"]);
}
function test_input($data) {
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
return $data;
}
?>
<form method="post" action="favorites.php">
Name: <input type="text" name="name">
<br><br>
FavoriteMovie: <input type="text" name="movie">
<br><br>
FavoriteFood: <input type="text" name="food">
<br><br>
season:
<input type="radio" name="gender" value="summer">summer
<input type="radio" name="gender" value="winter">winter
<input type="radio" name="gender" value="rainy">rainy
<input type="radio" name="gender" value="monsoon">monsoon
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
<?php
echo "<h2>Your Input:</h2>";
echo $name;
echo "<br>";
echo $movie;
echo "<br>";
echo $food;
echo "<br>";
echo $season;
echo "<br>";
?>
</body>
</html>
*********************
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.