View Full Version : Email form and response - how do I create both?
mike_g
05-27-2009, 03:53 PM
Forgive me if this has been answered; I was unable to find an answer searching here.
I'm trying to build a form that would generate two emails at the same time: one to the webmaster (the intended recipient) and the second to the person who filled out the form. Help?
Schmoopy
05-27-2009, 04:23 PM
Since I want to reduce the amount of modification required to your script can you please put up what you have so far?
mike_g
05-27-2009, 04:37 PM
You betcha:
<form id="contact" name="contact" method="post" action="/webformmailer.php">
<strong>Name*</strong><br />
<input name="name" type="text" id="name" size="40" maxlength="50" />
</p>
<p><strong>Email*</strong><br />
<input name="email" type="text" id="email" size="40" maxlength="55" />
</p>
<p><strong>Message*</strong><br />
<textarea name="message" cols="37" rows="7" id="message"></textarea>
*= required</p>
<p><label><input type="submit" name="send" id="send" value="Send Message" />
</label></p>
</form>
forum_amnesiac
05-28-2009, 05:52 AM
I don't know anything about webformmailer, but a lot of these scripts have the ability for a cc field to be passed so that you can send the email to 2 addresses.
If it doesn't have that ability then I would suggest that you look for one that does have this, or write your own, they are fairly simple for a basic email.
If however you want to have an HTML type email, ie the email is received in a 'formatted' state, eg can look like the input screen, then you need to use something more advanced, like Tectite Formmail.
mike_g
05-28-2009, 11:55 AM
@ forum_amnesiac
The webmailer is part of the hosting service; I'll check to see if it has a CC. Just in case, can you point me to some of that fairly basic code if I need to bypass it?
Thanks for your help!
forum_amnesiac
05-29-2009, 08:36 AM
This is a small script that I use to receive the contents of an enquiry form in a simple format.
It is very easy to use, just save this script as a PHP file, then in your HTML form use method="POST" action="scriptname.php".
You can add HTML insde the script to say "Thank You", or you can redirect to another page.
<?php
//variables
//form contents
$txtName=$_POST['name'];
$txtCategory=$_POST['category'];
$txtCompany=$_POST['company'];
$txtTel=$_POST['telephone'];
$txtEmail=$_POST['email'];
$txtRequest=$_POST['request'];
$txtName = str_replace(array("\n","\r"),'',$txtName);
$txtEmail = str_replace(array("\n","\r"),'',$txtEmail);
$txtCC="copyaddress@wherever.com";
$txtBCC="hiddenaddress@wherever.com";
$txtMyemail="myemail@wherever.com";
$message = "Category :\t$txtCategory\n
\nCompany :\t$txtCompany\n
\nName :\t$txtName\n
\nTelephone :\t$txtTel\n
\nEmail :\t$txtEmail\n
\nRequest :\t$txtRequest\n
\n";
$subject = "Request For Information - $txtName - $txtCompany";
$mailheaders = "From: $txtEmail <> \n";
$mailheaders .= "Reply-To: $txtEmail\n\n";
$mailheaders .= "CC: ".$txtCC."\n\n";
$mailheaders .= "BCC: ".$txtBCC."\n\n";
$sendemail =$txtMyemail;
//send mail
mail($sendemail, $subject, $message , $mailheaders);
?>
You can add whatever other field values, from your form, you want into $message as long as they are converted to PHP variables using the $_POST method shown in the script.
To send a copy to the person who filled out the form you would put their email address into the $txtCC variable.
The email is not formatted in any way, it is just a 2 column list of descriptions and entered values.
mike_g
05-29-2009, 12:26 PM
@ forum_amnesiac,
Thanks, this looks awesome. One more question, is it possible to add a custom message to the CC or BCC?
forum_amnesiac
05-29-2009, 01:06 PM
No, the message content has to be the same for all email addresses
Powered by vBulletin® Version 4.2.2 Copyright © 2021 vBulletin Solutions, Inc. All rights reserved.