HTML and CSS Reference
In-Depth Information
<
meta
http-equiv
=
”Content-Type”
content
=
”text/html; charset=UTF-8”
>
<
title
>
Simple E-Mail
</
title
>
</
head
>
<
body
>
<article>
<header>
<
h2
>
Mailer
</
h2
>
</header>
<section>
<header>
<
h3
>
Fill in the form and send us your questions, ideas, and rants.
</
h3
>
</header>
<
form
action
=
”mailer1.php”
method
=
”post”
>
<
input
name
=userName>
Please enter your name.
<
br
>
<
input
name
=mailNow
type
=email onInvalid=
”MailMaster.eMess()”
>
Enter e-mail address to send reply.
<
br
>
<
input
name
=subject>
What subject would you like to address?
<
br
>
<
fieldset
>
<
legend
>
Comments
</
legend
>
<
textarea
name
=talk
cols
=
70
rows
=
15
></
textarea
>
</
fieldset
>
<
input
type
=submit
name
=sender
value
=
”Send email”
>
</
form
>
</section>
</article>
</
body
>
</
html
>
339
One of the key lines in the HTML5 script is the action in the form that sends the information
to PHP for processing:
<
form
action
=
”mailer1.php”
method
=
”post”
>
h e form was not given a name because, for this application, we didn't need one. However,
adding a name to the form is generally a good practice, and if it's needed, it should be
available.
All the name attributes in the input elements are crucial. Each name in the input element tags
is passed to PHP as an array element in the
$_POST
array. h e element is then passed to a
variable that is used in the e-mail that is sent to a recipient — typically, the Web site owner. In
this case, that's you. Figure 16-5 shows the input page and the form data that will be sent to
the PHP program for server-side processing.
As soon as the user clicks the Send E-Mail button, he receives a notice:
Your e-mail has been sent to waz@wazooHome.net. Thank you for your interest in Wazoo
Web Site Design and Development.
To see how that happened, we'll have to look at the PHP portion of the application.