Question

In: Computer Science

Using PHP, create a form that uses the method GET. The form should capture a date...

Using PHP, create a form that uses the method GET.

The form should capture a date using two numbers

       Month (1 - 12) and Day (1 - 31)

Make sure the form is filled with the user's input after the form is submitted and processed, and the page is redisplayed.

If data is being passed into the page, then the page should display the date entered by the user and the season of the year. For example, if the user entered 10/12 (October 12), then the results would show something like this:

       The date 10/12 is in Fall.

Use these date ranges to determine the season

      Spring: March 21 - June 20

      Summer: June 21 - September 21

      Fall: September 22 - December 20

      Winter: December 21 - March 20

Solutions

Expert Solution

PHP CODE

<?php if (isset($_GET["Date"])){

   $Date=$_GET["Date"];
   $Month=$_GET["month"];
   $a=array('January', 'February', 'March');
   $b=array('April', 'May', 'June');
   $c=array('July', 'August', 'September');
   $season="";
   if (in_array($Month, $a)){
       $season = 'winter';
   }
  
   else if(in_array($Month, $b))
   {
       $season = 'spring';
   }
else if(in_array($Month, $c))
   {
       $season = 'summer';
   }


else{

   $season = 'Fall';
}

if (($Month == 'March') && ($Date >= 21)){
   $season = 'spring';
}
else if (($Month == 'June') && ($Date > 20)){
   $season = 'summer';
}
else if (($Month == 'September') && ($Date > 21)){
   $season = 'Fall';
}
else if (($Month == 'December') && ($Date > 20)){
   $season = 'winter';
}
  

}


?>
<!DOCTYPE html>
<html>
<head>
   <meta charset="utf-8">
   <meta http-equiv="X-UA-Compatible" content="IE=edge">
   <title>GET</title>
  
</head>
<body>
   <h1>DATE</h1>
   <form action="<?php $_PHP_SELF ?>" method="GET">
       <h2>Date</h2>
       <input type="text" value="<?php if(isset($Date)){ echo $Date;} ?>"name="Date" required>
       <h2>Date</h2>
       <input type="text" value="<?php if(isset($Month)){ echo $Month;} ?>" name="month" required>
       <input type="submit">
   </form>
   <?php
   if(isset($season)){
       echo "Season is: ".$season ;
   }
   ?>
</body>
</html>

------------------------

output

--------------------------

IF YOU HAVE ANY QUERY PLEASE COMMENT DOWN BELOW.
PLEASE GIVE A THUMBS UP


Related Solutions

Using PHP, Create a form that uses the method POST to send the information. The form...
Using PHP, Create a form that uses the method POST to send the information. The form should capture the distance the package needs to travel with the one field for the distance in miles. All fields should have the REQUIRED attribute. The form should have a submit button and reset button. The form should look nice. All the labels should line up horizontally and all the INPUTS/SELECT should line up horizontally.
2. Create a php program to get all the values from the forms using various methods...
2. Create a php program to get all the values from the forms using various methods and control structures like switch, if else, for, foreach, while, do while The question is required to write a program
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation...
Using PHP and MySQL Create a simple web form with at least 5 fields Include validation and error messages Create a MySQL Database Create a table to store submissions from the form Only insert new data into the database when all validation is passed Use PHP to create an HTML table showing all the content of the database   New submissions should appear in table
- Create an html form (bank form) and the PHP code with 2 accounts with options...
- Create an html form (bank form) and the PHP code with 2 accounts with options to transfer, deposit or withdraw money.
1. PHP OOP Create a complete PHP enabled website that defines and uses a PineApple class...
1. PHP OOP Create a complete PHP enabled website that defines and uses a PineApple class in PHP. The class has following members. Properties $color: string type $taste: string type $weight: number type Standard constructor, with 3 parameters Member functions eat(): no return, no parameter, print a short paragraph in English to describe how to eat a pineapple. grow(): no return, no parameter, print a short paragraph in English to describe how to grow a pineapple plant. display(): no return,...
Create a web page using PHP that allows the users to create an account (a username...
Create a web page using PHP that allows the users to create an account (a username and a password). There should be a login page that allows users to create an account by entering their preferred username and password. The same page should also let users login if they already have an account. If a user is logged in successfully , they should be able to enter a comment and also read the comments entered by others previously.
Using PHP, Make a form that allows the user to enter the weight of the item...
Using PHP, Make a form that allows the user to enter the weight of the item being shipped. This will be used to calculate the shipping cost.Create a form that uses the method POST The form should capture a customer's package weight with the one field for the package weight in pounds. All fields should have the REQUIRED attribute. The form should have a submit button and a reset button. The form should look nice. All the labels should line...
Utilizing PHP and HTML code Create a form that has text inputs for two numbers and...
Utilizing PHP and HTML code Create a form that has text inputs for two numbers and a submit button. Submit the values to a program that calculates and displays the GCD of the two numbers. The greatest common divisor of two integers a and b is the largest integer that is a factor of both a and b. The GCD of any number and 1 is 1, and the GCD of any number and 0 is that number. For example:...
Write a PHP program using HTML form. It will take Length, Width and Height of a...
Write a PHP program using HTML form. It will take Length, Width and Height of a box as input. When a button is pressed, it will calculate the Volume. If Volume is less than 25 then display the message “Small box”. If Volume is from 25 to 50, it will display the message “Medium box”. When the Volume is greater than 50, then display the message “Large box”.
Use what you learned in Chapter 19 to display the following date and time using php:...
Use what you learned in Chapter 19 to display the following date and time using php: Today is Tuesday October 6th. The current time is 14:07:29 PM PDT. Your display should appear exactly has displayed on separate lines. The date should be displayed using one function from the chapter and the time another.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT