Question

Using PHP, create a form that uses the method POST. The form should capture a month...

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

The form should capture a month and a year

      Month (1 - 12) and Year (any 4 digit year >= 1902 and < 2038)

The month is REQUIRED, but the year is optional.

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

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Done and tested in Xampp server. Please comment for any problem. Please Uprate. Thanks.

We are posting to same page and setting value of posted data to form as asked in question.

Code:

index.php

<?php
$message = "";
if(isset($_POST['submit'])){ //check if form was submitted
$month = $_POST['month']; //get input text for month
$year = $_POST['year'];
}else{
   $month = ''; //setting null if data is not posted
   $year = '';
}
?>

<html>
<body>
<form action="" method="post">
Month:<br>
<input type="number" name="month" min="1" max="12" value="<?php echo $month?>" required>
<br>
Year:<br>
<input type="number" name="year" min="1902" value=<?php echo $year?> max="2037">
<br><br>
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>

Output:

Add a comment
Know the answer?
Add Answer to:
Using PHP, create a form that uses the method POST. The form should capture a month...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • PHP you need to create a form to allow the user to enter their name, email,...

    PHP you need to create a form to allow the user to enter their name, email, and address information. That information will be sent to a PHP script that will process and display that information. Your assignment should have two pages. The first page is straight html (user_input.html) that has a form with the appropriate form elements to collect the user input. The form should then be submitted using the POST method to a php script (display_user_info.php) that will process...

  • Create web pages for your database using PHP. You should have one page that will return...

    Create web pages for your database using PHP. You should have one page that will return all the information from the database. You should create additional pages that will allow you to do various queries of your database. You should be able to retrieve and insert data; also include functionality to delete data from your database. Create an html form that will allow you to enter in new information for the database. The information should be handled by a PHP...

  • Create a list of several elements you think should make up a login page. Make sure to obtain instructor approval for the...

    Create a list of several elements you think should make up a login page. Make sure to obtain instructor approval for the elements of your login page. Consider the execution flow to capture the user interaction. Execute this assignment according to the following guidelines: 1.In MySQL, build the necessary tables to store the information required during the log in process. 2.In PHP, write the functions that will enable the capturing of user input and store in the database. 3.In HTML,...

  • Write a PHP program using a ''FOR loop' to compute and print the employee's salary for...

    Write a PHP program using a ''FOR loop' to compute and print the employee's salary for some number of years with a percent increase each year. Your submit button should re-call this page and use PHP to create a table of salaries for each year starting at 1 up to the value of the years variable. So if 'years' is equal to 5, there should be 5 rows in your table. For each year, the salary increases by X%. Make...

  • using PHP.... the code below is a shipping form that has one input text type to...

    using PHP.... the code below is a shipping form that has one input text type to enter the "package weight", destination with a select tag that has the option for New York or Out of State, insurance option with two radio buttons. radio value "yes" has a $10.00 insurance fee, and the no option has no fee, a submit button . all information is within a form with a method ="post" and an action ="<?php echo $_SERVER['PHP_SELF']; ?> <html> <head>...

  • Write a PHP script that obtains a URL and its description from user and stores the...

    Write a PHP script that obtains a URL and its description from user and stores the information into a database using MySQL. Create and run a SQL script with database named URL and a table named Urltable. The first field of the table should contain an actual URL, and the second, which is named Description, should contain a description of the URL. Use www.deitel.com as the first URL, and input Cool site! as its description. The second URL should be...

  • I NEED SOME HELP WITH THIS PLEASE :) 1. Create a data entry form on one...

    I NEED SOME HELP WITH THIS PLEASE :) 1. Create a data entry form on one of your web pages for visitors who want to be added to your mailing list. Include one of each of the following input elements*: Text <input type="text".... • Tel <input type="tel".... . Email <input type="email"... Date <input type="date"... . A set of radio buttons <input type="radio"... • A set of check boxes <input type="checkbox"... • A select element with options <select>.....</select> (do NOT add...

  • Create your page(s) using “’s Kung Fu Panda Po Sequence” as the page title(s) (tag). Save...

    Create your page(s) using “’s Kung Fu Panda Po Sequence” as the page title(s) (tag). Save the first page as index.htm (or index.php). Use a HTML form to capture user input. Submit the form to a second file index_process.php using the POST method. (3 points) The second page contains a link to go back to the first page. Allow the user to click on one of the four buttons. You must use for loop, while loop or do..while loop for...

  • Create a class called Date212 to represent a date. It will store the year, month and...

    Create a class called Date212 to represent a date. It will store the year, month and day as integers (not as a String in the form yyyymmdd (such as 20161001 for October 1, 2016), so you will need three private instance variables. Two constructors should be provided, one that takes three integer parameters, and one that takes a String. The constructor with the String parameter and should validate the parameter. As you are reading the dates you should check that...

  • 12. Suppose you are going to make an online questionnaire to collect information of current trend...

    12. Suppose you are going to make an online questionnaire to collect information of current trend of the social networking App. The questionnaire has already been drafted for you as shown below. When the questionnaire is submitted to the Web server, the server-side logic will check whether all necessary information has been entered. If not, an error message "The survey is not completed!” will appear on a web page and it will automatically divert the browser to the questionnaire page...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT