Web News


Canadian firms scoop interactive Emmy awards
Canadian new media firms have made a strong showing at the international Emmy awards for interactive content, taking two of four honours. Children's website Zimmer Twins by zinc Roe Design of Toronto and the...

How green can IT be?
Data centre energy consumption consortium The Green Grid has been fast acquiring new members like Microsoft, Dell, APC, VMWare, Intel, and Novell that all hope to get green while pulling in the green. Here we examine...

Canada falling behind in wireless
The federal government should speed up the auction of frequencies for a new generation of wireless devices, the head of Quebecor Inc. (TSX:QBR.B) said Tuesday arguing that a slow pace of change is putting...

Symantec eyes enterprise version of SaaS offering
Symantec Corp. wants to capture the online service market with the launch of its Symantec Protection Network, which will serve as a platform for offering its products and services under the software as a...


04.23.07


Nice PHP Contact Form Script & A Few Alterations

By Debbie Campbell

A colleague from the Women Designer's Group has
a great little PHP contact form script posted on her blog.

I recently used it for a client with just a bit of easy modification to the CSS styles to make it play nice with the rest of the page.

However, this client needed to have two different emails sent upon submitting the form - two emails with two different headers. Here's how you take care of that:

Download either script - the Simple one just has name, email and a textarea for comments, while the Complex one has other input elements like radio buttons and dropdown lists. I used the Simple one.

Open up index.php, this is the actual form processing script. Note that what I'm doing here is not the only customization you'll need to do to use this script! But it's very well-documented and should make sense to anyone with a smattering of PHP.

Scroll down to the bottom and find this section:

$mailheader = "From: $name < $email>nContent-Type: text/html";

mail("YOUR NAME OR COMPANY NAME HERE","$subject","$message","$mailheader");


The first line pulls the user's name and email from the form that's being processed and sets that up as the ‘from' information for the email that's coming to you.

Try a Better Way Today.
Try WebEx MeetMeNow -
Click Here

The second line is where the email's actually going - pretty self-explanatory. You enter your company name and email address, and it pulls in the subject (which you'll define earlier in this script), the message (which includes all the information the user submitted), and the mailheader (the ‘from' information above).

Pretty simple.

So what happens if you need to send two emails? What if you'd like one email to come to you, but you'd like another to go back to the user who filled out the form?

Not too difficult, really. What you'll do is create copies of the two lines shown above. We already have ‘$mailheader,' so just copy that and change it to ‘$mailheader2.'

For $mailheader2, let's change it so it indicates that it came from your company:

$mailheader2 = "From: YOUR COMPANY NAME \nContent-Type: text/html";

Now copy the ‘mail' line and we'll change that like so:

mail("YOUR COMPANY'S VISITOR < $email>","$subject","$message","$mailheader2");

This will send an email with the subject line ‘Your Company's Visitor' to the email address entered by the user, the subject line you created earlier in the script, the message containing all the data submitted by the user, and your second mailheader showing your company as the ‘From' address.

Make sense?

Comments

About the Author:
Debbie Campbell
Parallax Web Design | Web Design Blog

About DevWebProCanada
DevWebProCanada is for professional developers ... those who build and manage applications and sophisticated websites. DevWebProCanada delivers via news and expert advice New Strategies In Development.

DevWebProCanada is brought to you by:

SecurityConfig.com NetworkingFiles.com
NetworkNewz.com WebProASP.com
DatabaseProNews.com SQLProNews.com
ITcertificationNews.com SysAdminNews.com
LinuxProNews.com WirelessProNews.com
CProgrammingTrends.com ITmanagementNews.com


-- DevWebProCA is an iEntry, Inc. publication --
iEntry, Inc. 2549 Richmond Rd. Lexington KY, 40509
2007 iEntry, Inc.  All Rights Reserved  Privacy Policy  Legal 


archives | advertising info | news headlines | free newsletters | comments/feedback | submit article


Delivering IT Solutions DevWebProCanada News Archives About Us Feedback DevWebProCanada Home Page About Article Archive News Downloads WebProWorld Forums Jayde iEntry Advertise Contact