Click to See Complete Forum and Search --> : [RESOLVED] Make contact form send to email


stewart3000
12-14-2009, 03:15 PM
I have a template with a contact form made already in a div box, how to get it to send to email

I cant seem to get the red form box onto the page which I have used before with an extension.

this is the form


<div class="contactareas">
<div class="contactfillblank"><span class="banner_head1">If you have any questions, please fill out the form below and Ben will respond to you at the earliest.</span></div>
<div class="contactindicates"><span class="banner_head2"><span class="errortext">*</span>Indicates required fields </span></div>
<div class="contacttext" id="sub">Subject: </div>
<div class="contactdropdownmenu" id="subdtb">
<select name="select" class="dropdownEffect">
<option>General Enquiriy</option>
<option>Your Selection</option>
<option>Your Selection</option>
<option>Just to say hi</option>
</select>
<span class="errortext style2">*</span> </div>
<div class="contacttext" id="name">Your Name: </div>
<div class="contactformfield" id="nametextbox">
<input name="textfield22" type="text" class="textboxEffect" />
<span class="errortext style3">*</span> </div>
<div class="contacttext" id="business">Business Name: </div>
<div class="contactformfield" id="btextbox">
<input name="textfield222" type="text" class="textboxEffect" />
</div>
<div class="contacttext" id="email">Email Address: </div>
<div class="contactformfield" id="emailtextbox">
<input name="textfield2222" type="text" class="textboxEffect" />
<span class="errortext style3">*</span> </div>
<div class="contacttext" id="phno">Phone Number: </div>
<div class="contactformfield" id="phtextbox">
<input name="textfield22222" type="text" class="textboxEffect" />
<span class="errortext style3">*</span> </div>
<div class="contacttext" id="cno"> Mobile Number: </div>
<div class="contactformfield" id="celltextbox">
<input name="textfield222222" type="text" class="textboxEffect" />
</div>
<div class="contacttext" id="contactvia">Contact Via: </div>
<div class="contactdropdownmenu" id="div">
<select name="select2" class="dropdownEffect">
<option>Email</option>
<option>Phone Number</option>
<option>Mobile Number</option>
</select>
<span class="errortext">*</span> </div>
<div class="contactcommenttext" id="comm">Comments: </div>
<div class="contactformmsgfield">
<textarea name="textarea2" class="MassageboxEffect" cols="0" rows="0"></textarea>
</div>
<div class="contactsubmit">
<div align="left"><a href="#" class="css">Submit </a></div>
</div>

ryanbutler
12-14-2009, 07:51 PM
Well, you need to nest everything you wish to collect inside an opening and closing form tag. So it'd probably look like this:

<form method="post">
<div class="contactareas">
...rest of your code
</form>

Then, you'll need a script to process what was captured. Easiest would be PHP. If you use PHP, then you'll add an action attribute, with a PHP script set and then start creating the logic to send the email.

stewart3000
12-15-2009, 08:31 AM
Thanks got it working after putting it in the <form method="post">, </form> and used a free php form to mail scrip to link it up.

snaphead
01-15-2010, 07:17 PM
I am trying to learn so much at one time I am only concerning myself with the essentials right now. To transmit a form is php the recognized code or is javascript just as good.

thanks in advance

ryanbutler
01-16-2010, 11:35 AM
PHP or any server side language.

snaphead
01-16-2010, 04:35 PM
Do you essentially have to write a program that will extract the name/value pairs and save it to a txt file?

If so is there any good tutorials that explain how to do that.
I have 4 input text fields name email company and a text area.
is get or post better to use?
and do I have to write an extraction script and put it on my server?

Pardon my ignorance, thanks.

JS

Jerail
01-18-2010, 09:23 AM
Do you essentially have to write a program that will extract the name/value pairs and save it to a txt file?
Saving things to a log file would be one method...personally I prefer to have things sent directly to my e-mail.

If so is there any good tutorials that explain how to do that.
I have 4 input text fields name email company and a text area.
Sending e-mail with PHP is surprisingly simple. The basics of it are:
<?php
// This part just grabs all the info from your contact form. $_POST is called a superglobal,
// and it contains everything you sent to the PHP script from the form via the POST method.
$to = "Your Name <you@email.com>";
$subject = "contact_form";
$from = $_POST['name'] . ' <' . $_POST['email'] . '>';
// The message contains a line for the company name, and then the rest of the message
$message = 'Company: ' . $_POST['company'] . "\r\n\r\n";
$message .= $_POST['message'] . "\r\n\r\n";
$message .= $from;

// Now we have to format the e-mail headers
$headers = "From: $from";

// And send the e-mail on its way (and show error message if it doesn't work)
mail($to, $from, $subject, $headers) or die("ERROR");

// Give the client a success message:
echo "Message Sent!";

?>

The most important line is the mail($to,$from,$subject,$headers) function. That's the heart of it, and you essentially can send an e-mail with just that one single function! I would suggest that you read about it (http://php.net/manual/en/function.mail.php).

is get or post better to use?
For the purposes of a contact form, POST is better to use in my opinion. The difference is that GET actually displays everything in the query string. So when you click on submit with a GET submission form, it would send you to "email_handler.php?name=bill%20gates&email=bob@microsoft.com&company=microsoft&message=hey%20man%20whats%20up". This somewhat leaves the door open for spammers.

and do I have to write an extraction script and put it on my server?

Pardon my ignorance, thanks.

JS

snaphead
01-19-2010, 06:52 AM
Thank you for the detailed break down. I have become a little concerned about protecting the script from spammers and hackers using filters or strip functions. I do not know how to incorporate those into the script as well as feel confident I have covered all my bases. Most literature on the subject is too complex for me to grasp right now.

Thanks again for your help
js