PHP – Lesson 12: Creating an Email Form

This lesson demonstrates how to create a secure email contact form for users to use on your site. There are 8 video lessons in this series.

To get the starting file, you can download the attachment file (“contact_01.php.zip“) to this video. Additionally, you can start with the style sheet, as well (contact.css).


Email Form – Part 1  (16:10)

This movie covers the following topics:

  • Setting up the basic form in “contact_01.php” file
  • Delineation between different form tags and their attributes
  • $_SERVER[‘PHP_SELF’] as the form action

 


 

Email Form – Part 2 (9:55)

This movie covers the following topics:

  • working within the “contact_01.php” file
  • The difference between $_POST and $_GET

 


 

Email Form – Part 3 (18:27)

This movie covers the following topics:

  • working in the “contact_01.php” file
  • the mail() function
  • sending email with a basic, insecure, non-validating form

 


 

Email Form – Part 4 (11:26)

This movie covers the following topics:

  • the completion of “contact_01.php”
  • basic error reporting
  • initiation of “contact_02.php”

 


 

Email Form – Part 5 (21:43)

This movie covers the following topics:

  • stripslashes()
  • completion of “contact_02.php” file
  • initiation of “contact_03.php” file

 


 

Email Form – Part 6 (47:15)

This movie covers the following topics:

  • specific field error reporting
  • in_array()
  • array_push()
  • htmlentities()
  • completion of “contact_03.php” file
  • initiation of “contact_04.php” file

 


 

Email Form – Part 7 (36:03)

This movie covers the following topics:

  • start and end “contact_04.php”
  • preg_match() and regular expressions intro
  • security code for spam
  • security for email validation
    • $checkMail = ‘/^[^@]+@[^\s\r\n\'”;,@%]+$/’;

For more information on regular expressions and a healthy dose of self-punishment, visit:

~~~

 


 

Email Form – Part 8 (14:04)

This movie covers the following topics:

  • adding additional headers to your script (From:, Reply-To:, Cc:, Bcc:, etc).