Contact Us PHP Assignment

From Knowledge Kitchen
Jump to navigation Jump to search


Assignment

Create a functional "Contact Us" form.

  1. Users should see a form with fields for their name, email address, and a free-form message.
  2. Clicking a submit button sends the message as an email to the webmaster (you).
  3. The user then sees a Confirmation screen indicating that their message has been sent.

Hints

The form is simply an HTML form with input and textarea fields.

  • Be sure to give each of your form elements the "name" attribute.
  • Set the form's "method" attribute to indicate that is should use the HTTP POST method when submitting.
  • Set the form's "action" attribute to point a PHP script that sends the email.

The PHP script receives the HTTP POST data automatically into PHP's built-in $_POST array.

  • store the user's name, email address, and message into distinct PHP variables.
  • hard-code the webmaster's email address in a variable.
  • use PHP's built-in mail() method to send the email
  • use PHP's built-in header() method to modify the server's HTTP Response "Location" header. Changing this header makes the browser think that the page it requested has been moved to a new location, and the browser continues to request the page at the new location.


The confirmation page can be a simple HTML page.


What links here