Some do-gooder's magic_quotes idea was helpful to the point of annoying, eh? I think I read somewhere that I turn that off by using an .htaccess file (but make sure all your PHP stuff is compatible without magic_quotes before you do that, I would imagine).
If you're doing this alone, you're kicking some serious tail.
Yes, I've actually spent many more hours cajoling it into the shape I want! It's working great.
I did have questions about the paint_value operation. After some wrangling, I managed to organize everything correctly but learned that it does not work for radios and selects. If you have (or anyone lurking has!) a free moment to point me in the right direction, that would be helpful. I searched google for examples of "php post form values" but that was a mess.
Okay, I want to leave a tip for anyone else reading this tutorial, after working on this a while. You'll notice that when you receive the email from your contact form, it does not have the sender's actual name in the from field. But you can fix that by modifying a couple lines in Step 12.
Code: Select all
/** 12 **/
//Try sending the email.
// Redirect to success page on success, or form on failure
if ($swift->send("yourname@example.com", $email, $subject))
The reason why, as you see, is the second value could have been "My Name" <
sender@somewhere.com> but it is only inserting the email address. If you want the name to appear, then you could replace it with this
Code: Select all
/** 12 **/
//setup the sentfrom
$sentfrom = '"' . $user_name . '" <' . $email . '>';
//Try sending the email.
// Redirect to success page on success, or form on failure
if ($swift->send("yourname@example.com", $sentfrom, $subject))
Or, if you're like me and separated first and last name to two different input boxes, then you can do this instead.
Code: Select all
/** 12 **/
//setup the sentfrom
$sentfrom = '"' . $firstname . ' ' . $lastname . '" <' . $email . '>';
//Try sending the email.
// Redirect to success page on success, or form on failure
if ($swift->send("yourname@example.com", $sentfrom, $subject))
Just be sure to watch those quotes! They change from ' and " in a specific way... and cost me a dear amount of time to sort that out properly.
EDIT
Here's another tip. If you want to send to the contact form email to multiple people, you can follow the ideas shown here.
http://www.swiftmailer.org/docs/tutorials/batch-mailing
Now, if you're similar to me and MySQL looks like mumbo jumbo, then you can just type the list out. Basically, you follow the pattern laid out on that page, which after some trial-and-error successfully looks something like this.
Code: Select all
/** 12 **/
//setup the sentfrom
$sentfrom = '"' . $firstname . ' ' . $lastname . '" <' . $email . '>';
//sent to multiple people
$sendtolist = array ("yourname@example.com", "yourfriend@gmail.de", "yourboss@whipcrackers.net");
//Try sending the email.
// Redirect to success page on success, or form on failure
if ($swift->send($sendtolist, $sentfrom, $subject))