Current location: Hot Scripts Forums » Programming Languages » PHP » Formmail question


Formmail question

Reply
  #1 (permalink)  
Old 12-28-04, 12:32 PM
sixflagsga sixflagsga is offline
Newbie Coder
 
Join Date: Sep 2004
Location: Atlanta, Georgia
Posts: 40
Thanks: 0
Thanked 0 Times in 0 Posts
Formmail question

I see on some forms that you send out on websites that you receive an email back with an autoresponder. Like, on my website, when guests go to a form (http://www.sfogonline.com/index.php?page=contactjesse) they get a form. After filling it out, they are sent to a thank you page or a required page if they don't fill out all the fields. My question is, can I send an email automatically (HTML) through the field "email" to that email address. So, if the fill out "whatever@gmail.com", it automatically sends an HTML email to that address, since he filled that out in the email field...thanks for the help in advance!
Reply With Quote
  #2 (permalink)  
Old 12-28-04, 01:32 PM
bizzar528's Avatar
bizzar528 bizzar528 is offline
Community Liaison
 
Join Date: Sep 2004
Location: Pennsylvania, US
Posts: 1,550
Thanks: 2
Thanked 16 Times in 15 Posts
yep, it's possible.

First, you have to capture the email address from the forum, usually from a GET or POST method. I'll pretend POST for the sake of example, but there's a few ways to do this.

$email = $_POST['emailaddress'];

Then, you can run some post validation. This can be done via javascript when the form is submitted, or via php from the page that your results are sent to. I prefer the second method since not everyone has javascript capability turned on and it can cause some funk. The validation can spit out an error message if the form wasn't filled out or is missing fields. There are a few form validation scripts/classes on hotscripts, just run a search.

Then, you can mail a message back to the person.

mail($to, $subject, $message, $headers);

$message will contain your HTML code if you want an html email, or it can also be a plain text. Just keep in mind what your working towards when your writing your script.

$headers is what will tell email clients how to process the message. usually, $headers will just contain the from address. For example

$header = "From: Biz<email@duhme.com>";

But it can also be used to specify that the email is html and should be processed as such.

Example:
$header = "From: Biz<email@duhme.com>";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";

You can find more options by visiting the PHP mail() page at: http://us4.php.net/manual/en/function.mail.php
__________________
Yep, it's a signature...
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Posting a question / answer on site markcody PHP 2 11-23-04 01:58 PM
formmail problem gscraper Perl 12 08-27-04 03:06 AM
[PHP] Array question UmiSal Script Requests 1 04-05-04 01:52 PM
question and answer software jaydifox C/C++ 0 02-21-04 09:26 AM
ADO Recordsets question vbNovice Visual Basic 0 12-22-03 10:25 PM


All times are GMT -5. The time now is 05:23 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.