Send dreamweaver form to email

January 11, 2010 at 18:41:23
Specs: Windows XP
Hi,

I have recently designed a website for my new business. I have included a booking form which can be found here www.n-v-m.co.uk/Booking.html

I used Dreamweaver CS4 to create the site and 123-reg.co.uk is my web host

As it’s my first attempt at making a website I realise I may have constructed the site incorrectly. Please (for now) do not give me advice on how to make the site faster/tidier. All I wish to know is how to get the Booking Form working so that it sends information from the form to my email address.

Currently, on clicking the ‘Submit’ button the browser opens the customers email programme but I really require for the information to sent automatically back to my email address and then have the browser re-direct to www.n-v-m.co.uk/Thankyou.html

I have looked around a few forums and it seems I may need a PHP script but have no idea how to do this. Can anybody please explain what I must do? I would prefer not to have to spend any money if possible!

Thanks

Paul.

Ps. I also require the form to prevent the customer to ‘Submit’ unless ‘Is Vehicle roadworthy with full M.O.T.:’ is set to ‘Yes’ and the ‘I agree with the Terms and Conditions’ box is checked... but this is not as desperate.


See More: Send dreamweaver form to email

Report •

#1
January 13, 2010 at 05:41:04
build a php page (filename.php) and link your form to it with the method POST;

copy paste the code bellow to filename,

with this code u will get company, name, phone & email there is also some methods of checking the data but still u need to work a bit more to get the whole form emailed by php
<?php
//---------------------------------------------------------
$company =$_POST['Company'];
$name=$_POST['Name'];
$phone=$_POST['Phone Number'];
$email=$_POST['Email'];
//---------------------------------------------------------
$ip = $_SERVER['REMOTE_ADDR'];
//---------------------------------------------------------

if(check_email_address($email)) { sendEmail(); }
else{ echo 'wrong email address, please check your email and try again. '; }

function sendEmail()
{

$Subject = "welldone from interactive10.com";
echo 'email is send';
// sending the email
$msg = 'company ' . $company . ' name ' . $name . ' phone ' . $phone . ' email ' . $email;
$to = 'test@n-v-m.co.uk';// put yout email here
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
$headers .= "From: $email \r\n";
if(mail($to, $Subject, $msg, $headers)){echo ' done';} else{echo ' Error';}
echo '<br />';
}

//
function check_email_address($email) {
// First, we check that there's one @ symbol,
// and that the lengths are right.
if (!ereg("^[^@]{1,64}@[^@]{1,255}$", $email)) {
// Email invalid because wrong number of characters
// in one section or wrong number of @ symbols.
return false;
}
// Split it into sections to make life easier
$email_array = explode("@", $email);
$local_array = explode(".", $email_array[0]);
for ($i = 0; $i < sizeof($local_array); $i++) {
if
(!ereg("^(([A-Za-z0-9!#$%&'*+/=?^_`{|}~-][A-Za-z0-9!#$%&
?'*+/=?^_`{|}~\.-]{0,63})|(\"[^(\\|\")]{0,62}\"))$",
$local_array[$i])) {
return false;
}
}
// Check if domain is IP. If not,
// it should be valid domain name
if (!ereg("^\[?[0-9\.]+\]?$", $email_array[1])) {
$domain_array = explode(".", $email_array[1]);
if (sizeof($domain_array) < 2) {
return false; // Not enough parts to domain
}
for ($i = 0; $i < sizeof($domain_array); $i++) {
if
(!ereg("^(([A-Za-z0-9][A-Za-z0-9-]{0,61}[A-Za-z0-9])|
?([A-Za-z0-9]+))$",
$domain_array[$i])) {
return false;
}
}
}
return true;
}
?>


Report •

#2
January 13, 2010 at 16:21:48
Thanks for the reply.

I did what you said but now when i click submit the browser just tries to download the php file which i have named sendform.php. To see for yourself please check out http://www.n-v-m.co.uk/Booking.html

I have included the whole code for the Booking Form page below just in case it helps (as stated in my previous post the code may look a bit messy - please ignore this if you can)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>National Vehicle Movements - Booking Form</title>
<style type="text/css">
<!--
body {
background-color: #1d255f;
margin: 0px;
padding: 0px;
}
#apDiv1 {
position:absolute;
width:487px;
height:706px;
z-index:auto;
left: 50%;
top: 433px;
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
text-align: center;
background-position: center;
margin-left: -244px;
}
-->
</style></head>

<body>
<div align="center">
<div id="apDiv1">
<form id="form1" name="form1" method="post" action="sendform.php">

<strong>Company:
<input type="text" name="Company" id="Company" />
</strong></p>
<p class="text"><strong>Name:
<input type="text" name="Name" id="Name" />
</strong></p>
<p class="text"><strong>Phone Number:
<input type="text" name="Phone Number" id="Phone Number" />
</strong></p>
<p class="text"><strong>Email Address:
<input type="text" name="Email" id="Email" />
</strong></p>
<p class="text"><strong>Vehicle Make and Model:
<input type="text" name="Vehicle Make and Model" id="Vehicle Make and Model" />
</strong></p>
<p class="text"><strong>Vehicle Reg./Ref. No.:
<input type="text" name="Vehicle Reg." id="Vehicle Reg." />
</strong></p>
<p class="text"><strong>Collection Address including Postcode:
<input type="text" name="Collection Address" id="Collection Address" />
</strong></p>
<p class="text"><strong>Collection Contact Name:
<input type="text" name="Collection Contact Name" id="Collection Contact Name" />
</strong></p>
<p class="text"><strong>Collection Contact Number:
<input type="text" name="Collection Contact Number" id="Collection Contact Number" />
</strong></p>
<p class="text"><strong>Delivery Address including Postcode:
<input type="text" name="Delivery Address" id="Delivery Address" />
</strong></p>
<p class="text"><strong>Delivery Contact Name:
<input type="text" name="Delivery Contact Name" id="Delivery Contact Name" />
</strong></p>
<p class="text"><strong>Delivery Contact Number:
<input type="text" name="Delivery Contact Number" id="Delivery Contact Number" />
</strong></p>
<p class="text"><strong>Collection Date/Time:
<input type="text" name="Collection Date/Time" id="Collection Date/Time" />
</strong></p>
<p class="text"><strong><em>(if possible please give a time window eg. '7th - 9th August' and we will arrange collection for you)</em></strong></p>
<p class="text"><strong>Delivery Date/Time:
<input type="text" name="Delivery Date/Time" id="Delivery Date/Time" />
</strong></p>
<p class="text"><strong><em>(if possible please give a time window eg. '7th - 9th August' and we will arrange delivery for you)</em></strong></p>
<p class="text"><strong>Is Vehicle Taxed:
<select name="Is Vehicle Taxed" id="Is Vehicle Taxed">
<option>Yes</option>
<option>No</option>
</select>
</strong></p>
<p class="text"><strong>Is Vehicle roadworthy with full M.O.T.:
<select name="Is Vehicle Roadworthy with Full M.O.T." id="Is Vehicle Roadworthy with Full M.O.T.">
<option>Yes</option>
<option selected="selected">No</option>
</select>
</strong></p>
<p class="text"><strong>Billing Address:
<input type="text" name="Billing Address" id="Billing Address" />
</strong></p>
<p class="text"><strong><em>(if same as collection or delivery address please enter 'collection' or 'delivery')</em></strong></p>
<p class="text"><strong>Customer Ref./Order No.:
<input type="text" name="Customer Ref./Order No." id="Customer Ref./Order No." />
</strong></p>
<p class="text"><strong>Any additional comments:
<input type="text" name="Any additional comments" id="Any additional comments" />
</strong></p>
<p class="text"><strong>
<input type="checkbox" name="checkbox" id="checkbox" />
I agree with the <u>Terms and Conditions</u></strong></p>
<p class="text"><strong>
<input type="submit" name="button" id="button" value="Submit order" />
<input type="reset" name="button2" id="button2" value="Reset form" />
</strong></p>
</form>

 </p>
</div>
</div>
<div align="center">
<map name="Map" id="Map">
<area shape="rect" coords="28,175,151,191" href="Prices.html" alt="Prices" />
<area shape="rect" coords="36,156,159,173" href="index.html" alt="Home" />
<area shape="rect" coords="476,193,575,206" href="mailto:info@n-v-m.co.uk" alt="Email us" />
</map>
</div>
</body>
</html>

Any further help would be much appreciated.

Thanks

Paul


Report •

#3
January 18, 2010 at 10:06:22
You can take advantage php form for a problem exception:

<form>

<table>

<tr>

<td>Name *</td>

<td><input type="text"></td>

</tr>

<tr>

<td>Email *</td>

<td><input type="text"></td>

</tr>

<tr>

<td>Phone</td>

<td><input type="text"></td>

</tr>

<tr>

<td>Field_check</td>

<td>

<input type="checkbox" value="1"><label>Check_1</label>


<input type="checkbox" value="2"><label>Check_2</label>


<input type="checkbox" value="3"><label>Check_3</label>

</td>

</tr>

<tr>

<td>Message *</td>

<td><textarea rows="5"></textarea></td>

</tr>

<tr>

<td colspan="2"> </td>

</tr>

<tr>

<td colspan="2"> </td>

</tr>

<tr>

<td><input type="button" id="subbut" value="Submit"></td>

</tr>

</table>

</form>

For more detailed solution read the text on this a web to page.


Report •
Related Solutions


Ask Question