7 Form Handling And Http Methods

Web Technology II · Unit 7

Form Handling and HTTP Methods

Exam-focused notes for Form Handling and HTTP Methods (Web Technology II, BIT301): what the TU syllabus asks and how it has actually been tested, with 5 solved past questions from this unit.

What this unit covers

  • Form data retrieval
  • GET method and query strings
  • POST method and request body
  • GET versus POST comparison
  • Form elements and input fields
  • Form submission and event handling
  • Response headers and redirects

Response headers and redirects

208210 marks

What are the response headers? Create a PHP login form that contains username, password and a login type field defined by dropdown menu. The login type options can be normal or admin. Now, write a function for implementing the login event. The event should be redirected to admin.php if the login credentials match and if the login type is admin otherwise it should be redirected to hello.php. Create a proper database connection based on your own assumption.[10]

A response header is a line of metadata that the server sends back to the browser ahead of the response body, in the header block of the HTTP response. The body says what the page contains, the headers say how the browser should treat it: what media type it...

Full solved answer →

GET versus POST comparison

20825 marks

Differentiate GET method from POST method with examples. [5]

GET and POST are two fundamental HTTP methods used to send requests from a client (browser) to a server. They differ in how data is transmitted and their intended use cases. --- Feature GET Method POST Method --------- Data Transmission Data is appended to ...

Full solved answer →

Form submission and event handling

207910 marks

Consider you have a login form having username, password fields, login and cancel buttons. Now, write a PHP program for implementing login event. The login should be redirected to home.php upon successful login button event. The cancel button should clear the form field values upon its submission.[10]

Both buttons are submit buttons inside the same form, and each carries its own name. A browser posts only the button that was actually pressed, so the script can ask isset($POST['login']) or isset($POST['cancel']) and know which event it is handling. That i...

Full solved answer →

Form data retrieval

20795 marks

How can you retrieve the form data? Illustrate with example. [5]

When a form is submitted the browser sends the field values to the server, and PHP unpacks them into superglobal arrays that are available in every scope without being declared. Superglobal Holds ------ $GET Values from the query string, so from a form with...

Full solved answer →
010 marks

How can you retrieve form data? Write a PHP program to create a form data that will take a Fahrenheit value as input and displays equivalent Celsius value on submit. The Celsius = (5/9)*(Fahrenheit-32).[10]

An HTML form sends its field values to the server when it is submitted, and PHP unpacks them into superglobal arrays, so called because they are available in every scope without being declared. Which array a value lands in depends on the form's method. Supe...

Full solved answer →