This script is widely used by many sites on the net. PHP provides an easy way to send mail via the function mail().
First of all, we ought to prepare the adequate fields to be filled by the user.
Ex: Name, E-Mail, Subject, Body
Now we start coding :
<HTML> ?> |
Now we're going to work inside PHP braces ( <? ?>)
It's quite easy to write HTML code for a form. Just copy this:
<form method=POST name=form1> |
Since PHP is case sensitive, beware when writing field names (write low-case names).
Now, we've got to remember that our page is composed of "two pages": the first one contains the form and the second one sends the mail and displays "Thank You For using our mail form"
So, we use a condition :
if ($submit) ( as we named our button submit)
This HTML code should only appear when the user is not submitting his message. So, the code becomes:
<HTML> |
Now we have to add the script to send the mail.
Here it is:
<? |
So the final thorough script becomes :
<HTML> |
Related Articles
- Form Mail via CDONTSASP gives you the power to send mail using the CDONTS mail object. This script will send an email from a user to whichever email address you choose...
- E-mail form using HTML and PHPSometimes its a nice touch to include an e-mail feedback form on your contact page or elsewhere on your web site. Lets create an e-mail form using html and a simple php script to send it along.
- How to make a simple form mailer with PHPAs you may be well aware, displaying your e-mail address on your website can lead to e-mail harvesters picking up your address and adding it to hundreds or even thousands of lists used by spammers...
- Guide to Logo DesignThis excellent tutorial entitled Guide to Logo Design is a quick overview of concept design and the visual design of a logo. Any logo must be easily recognized and appreciated.
- PHP Feedback Form: AdvancedThe problem with my basic PHP Mail Form tutorial is that it offers no protection from spam and meta tag injection. This is fine if you have a very low-traffic site not listed at major search engines, or have a private website, but bigger sites need more.
- Do not post to FFA's (Free For All Sites) & Link FarmsIn this tutorial Martin Lemieux presents a compelling case for why you should not use Link Farms and FFAs to promote your business.
- Form EmailLearn to send mail with the php mail(); function.
- Contact FormHere I will explain to you how you can create a simple contact form. The form will collect data from the visitor and send it to any email address you please. The only requirement for this tutorial is for you to have .php enabled on your server. If you dont want to read through the whole tutorial a....
- Form Validation using PHPToday Ill take it up a level and re-write that script using the if, else conditional and empty() function to include form validation.
- Create a Contact Page with HTML and PHPI have made a tutorial about how to install EasyPhp and now i come with an example. Today we learn how to create a Contact Page in HTML and PHP very easy! Download the next files to exercise on them:
