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.

use this type of code structure...

<?php

$Name = "Da Duder"; //senders name
$email = "email@adress.com"; //senders e-mail adress
$recipient = "PersonWhoGetsIt@emailadress.com"; //recipient
$mail_body = "The text for the mail..."; //mail body
$subject = "Subject for reviever"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields

ini_set('sendmail_from', 'me@domain.com'); //Suggested by "Some Guy"

mail($recipient, $subject, $mail_body, $header); //mail command :)
?>

Thanks for the reply but as I am completely new to all this can you please explain where to insert the code

ok dear!

Can I have that code, by which you have designed that form ?

Anyways ! If I have this code as a form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
 <div align="center">
<form method="POST" action="test2.php">
What is Your Name : <input type="text" name="nm">
<br>
What is your Email Address : <input type="text" name="email">
<br>
Please enter your content here ! : <input type="text" name="content">
<br>
<input type="submit" name="sumbit" value="Send to us !">
</form>
</div>

 </BODY>
</HTML>

Then i will make a new php file which contain the below code, named test2.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
  <?php
$Name = $_POST['name']; //senders name
$email = $_POST['email']; //senders e-mail adress
$recipient = "harshbavaliya@gmail.com"; //recipient
$mail_body = $_POST['content']; //mail body
$subject = "Mail From Website Visitor"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
 
mail($recipient, $subject, $mail_body, $header); //mail command :)
if(mail)
	echo "Okey! We Are Proceed. Thank You !";
else
	echo "Sorry We Can't Proceed, Please Try After Some Time!";
?>
</BODY>
</HTML>

Have a great day.... ;)

Thanks for the reply.

I think the best way to do this is, as you suggested, to post the whole code for my booking page which can be found here www.n-v-m.co.uk/Booking.html

As stated in my initial 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

sorry that was wrong... just use this....

<!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="test2.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="phonenum" 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="vmam" id="Vehicle Make and Model" />
</strong></p>
<p class="text"><strong>Vehicle Reg./Ref. No.:
<input type="text" name="vreg" id="Vehicle Reg." />
</strong></p>
<p class="text"><strong>Collection Address including Postcode:
<input type="text" name="colladd" id="Collection Address" />
</strong></p>
<p class="text"><strong>Collection Contact Name:
<input type="text" name="collconname" id="Collection Contact Name" />
</strong></p>
<p class="text"><strong>Collection Contact Number:
<input type="text" name="Collconnum" id="Collection Contact Number" />
</strong></p>
<p class="text"><strong>Delivery Address including Postcode:
<input type="text" name="deladd" id="Delivery Address" />
</strong></p>
<p class="text"><strong>Delivery Contact Name:
<input type="text" name="delconname" id="Delivery Contact Name" />
</strong></p>
<p class="text"><strong>Delivery Contact Number:
<input type="text" name="delconnum" id="Delivery Contact Number" />
</strong></p>
<p class="text"><strong>Collection Date/Time:
<input type="text" name="collectiondt" 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="deliverydt" 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="billadd" 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="custordnum." id="Customer Ref./Order No." />
</strong></p>
<p class="text"><strong>Any additional comments:
<input type="text" name="aaddcomm" 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>

in this i have just edited your code by changing the name of input type...
now we can access that values by using _POST and the php file...

now you just have to do is just save all that data to some variables.. ok?

let me tell you how to store that data in a variable....
if you want to store name variable then just user this

$name=$_POST['name'];

save every variable got from the form....
I think it will be so easy for you dear :)

and then you can use this codes...

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>
 
 <BODY>
  <?php
$Name = $_POST['name']; //senders name
$email = $_POST['email']; //senders e-mail adress
$recipient = "harshbavaliya@gmail.com"; //recipient
$mail_body = $_POST['content']; //mail body
$subject = "Mail From Website Visitor"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
 
mail($recipient, $subject, $mail_body, $header); //mail command :) you can add any variable here... I know you have so many, but it is possible...
if(mail)
	echo "Okey! We Are Proceed. Thank You !";
else
	echo "Sorry We Can't Proceed, Please Try After Some Time!";
?>
</BODY>
</HTML>

Anyways! I can give you full code but i am not giving. Because some work must be done from your sight.
Have a Great Day :)

You are absolutely right harshbavaliya

okey then, the problem has been solved.....

then just click on SOLVED link....
:)

Sorry, unfortunately this problem isn't solved for me yet...

I have used the code you gave me and now on clicking submit the browser just sends me to a blank screen and I receive no email. Please feel free to look for yourself at www.n-v-m.co.uk/Booking.html

Here is the code I am using for the Booking Form now:

<!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">
      <p><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="phonenum" 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="vmam" id="Vehicle Make and Model" />
      </strong></p>
      <p class="text"><strong>Vehicle Reg./Ref. No.:
        <input type="text" name="vreg" id="Vehicle Reg." />
      </strong></p>
      <p class="text"><strong>Collection Address including Postcode:
          <textarea name="colladd" rows="4" id="Collection Address"></textarea>
      </strong></p>
      <p class="text"><strong>Collection Contact Name:
        <input type="text" name="collconname" id="Collection Contact Name" />
      </strong></p>
      <p class="text"><strong>Collection Contact Number:
        <input type="text" name="collconnum" id="Collection Contact Number" />
      </strong></p>
      <p class="text"><strong>Delivery Address including Postcode:
          <textarea name="deladd" rows="4" id="Delivery Address"></textarea>
      </strong></p>
      <p class="text"><strong>Delivery Contact Name:
        <input type="text" name="delconname" id="Delivery Contact Name" />
      </strong></p>
      <p class="text"><strong>Delivery Contact Number:
        <input type="text" name="delconnum" id="Delivery Contact Number" />
      </strong></p>
      <p class="text"><strong>Collection Date/Time:
        <input type="text" name="collectiondt" 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="deliverydt" 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="billadd" 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>Your Customer Ref./Order No. (if any):
          <input type="text" name="custordnum" id="Customer Ref./Order No." />
      </strong></p>
      <p class="text"><strong>Any additional comments:
          <textarea name="addcom" rows="3" id="Any additional comments"></textarea>
      </strong></p>
      <p class="text"><strong>
        <input type="checkbox" name="checkbox" id="checkbox" />
        I agree with the <u><a href="Terms.html">Terms and Conditions</a></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>&nbsp;</p>
</div>
</div>
<div align="center"><img src="images/Booking_03.jpg" width="680" height="1352" border="0" usemap="#Map" />
  <map name="Map" id="Map">
    <area shape="rect" coords="475,191,578,206" href="mailto:info@n-v-m.co.uk" alt="Email us" />
    <area shape="rect" coords="36,155,158,173" href="index.html" alt="Home" />
    <area shape="rect" coords="29,174,151,189" href="Prices.html" alt="Prices" />
  </map>
</div>
</body>
</html>

and here is the code I have entered into the php file "sendform.php" (I realise I have not entered all the fields I require as yet but will do this once I have rectified this problem)

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>
 
 <BODY>
  <?php
$Name = $_POST['name']; //senders name
$email = $_POST['email']; //senders e-mail address
$recipient = "info@n-v-m.co.uk"; //recipient
$mail_body = $_POST['name']; //mail body
$subject = "Mail From Website Visitor"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
 
mail($recipient, $subject, $mail_body, $header); //mail command :) you can add any variable here... I know you have so many, but it is possible...
if(mail)
	echo "Okey! We Are Proceed. Thank You !";
else
	echo "Sorry We Can't Proceed, Please Try After Some Time!";
?>
</BODY>
</HTML>

Paul.

I have also tried the code you sent me below as a test but on clicking "Send to us !" the browser just opens the php file in dreamweaver when I assume I should be getting the message "Okey! We Are Proceed. Thank You !"??

Does this mean there is a problem with my hosting?

Anyways ! If I have this code as a form

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
 <div align="center">
<form method="POST" action="test2.php">
What is Your Name : <input type="text" name="nm">
<br>
What is your Email Address : <input type="text" name="email">
<br>
Please enter your content here ! : <input type="text" name="content">
<br>
<input type="submit" name="sumbit" value="Send to us !">
</form>
</div>

 </BODY>
</HTML>

Then i will make a new php file which contain the below code, named test2.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML>
 <HEAD>
  <TITLE> New Document </TITLE>
  <META NAME="Generator" CONTENT="EditPlus">
  <META NAME="Author" CONTENT="">
  <META NAME="Keywords" CONTENT="">
  <META NAME="Description" CONTENT="">
 </HEAD>

 <BODY>
  <?php
$Name = $_POST['name']; //senders name
$email = $_POST['email']; //senders e-mail adress
$recipient = "harshbavaliya@gmail.com"; //recipient
$mail_body = $_POST['content']; //mail body
$subject = "Mail From Website Visitor"; //subject
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
 
mail($recipient, $subject, $mail_body, $header); //mail command :)
if(mail)
	echo "Okey! We Are Proceed. Thank You !";
else
	echo "Sorry We Can't Proceed, Please Try After Some Time!";
?>
</BODY>
</HTML>

Have a great day.... ;)

Please ignore my last 2 posts... I found out I had to upgrade my web hosting.

Cheers.

Paul

okey! now you just understand that code....

when we are using

if(mail)
	echo "Okey! We Are Proceed. Thank You !";
else
	echo "Sorry We Can't Proceed, Please Try After Some Time!";

and if we get first massage then it means that the mail function was successful... so there are not any mistakes in our code...

anyways just upgrade your web host, definitely it will work dear !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.