hi there, i have created a php website for my mobile DJ business, and want a booking enquiry form so people can fill out their details and email the data to us and we can then contact them about their booking.
I have created the form in html, and using an index.php file and the include code to load the html form in the page. you can view the file at:
http://voguefm.co.uk/xfaders/site/modules.php?name=Booking_Form
it is an inactive module at the moment.
basically i have experimented with using a sendmail.php file but i dont really have enough knowledge of php to get it to work properly.
I have created a script that sends me an email with the correct subject title but with no content in the main message of the email.:sad:
can anyone help me create a sendmail.php file that will send all of the data in the form? is it even possible? as it uses tick boxes and drop down menu's.

hopefully that can be understood by someone!
thanks for your help

Your php page that you use after the form is submitted would have to check all the check boxes to to see if they are checked:

if(isset($_POST['checkboxname']))
{
 
  $somevalue = "yes";
 
}
else
{
 
  $somevalue = "no";
 
}

Personally I would load all the form variables into variables to make things easier to manage and look at.

At this point you would create the actual mail script including all the info you need.

The basic setup to send mail is as follows:

mail(e-mail address to send to,subject,body,from)

Usualy this is put in an if statement just for error purposes if it does not work.

Here is an example contact us form that I have available for download on my site.

<?
////////////////////////////////////////////////////////
//
// THIS CODE WAS CREATED BY ETYN.COM
// YOU MAY USE THIS CODE FOR FREE
// BUT THIS MESSAGE MUST STAY INTACT
//
///////////////////////////////////////////////////////
 
$formgood = true;
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$to = "[EMAIL="user@mail.com"]user@mail.com[/EMAIL]"; //Please change this to your e-mail address
$message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email";
//check to make sure all form elements were filled in
if ($name == "") {
    echo 'You must provide your name to contact us. Please click the back, and try again';
 $formgood = false;
}
if ($email == "") {
    echo 'We require an e-mail address in order for us to respond. Please go back and try again.';
 $formgood = false;
}
if ($comments == "") {
    echo 'You must provide comments in order to submit this form. Please click back, and try again.';
 $formgood = false;
}
if ($formgood) {
    if(mail($to, "A contact us form has been submitted by $name", $message, "From: $email\n")) {
   echo 'Thank you for submitting this form. We will review your comments and contact you shortly. <br><br> Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.';
}
else
{
echo "An error has occured. Please contact the webmaster.";
}
 }
else {
  
echo "<br> Please review the comments above and try again.";
       
echo '<br>Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.';
}
?>

that script works fine, thank you very much!
so if i wanted to add a field for a telephone number i would create the field in the html page. naming is 'telephone'
and in the PHP script it would look like this:

<?
////////////////////////////////////////////////////////
//
$formgood = "t";
$telephone = $_POST['telephone'];
$name = $_POST['name'];
$email = $_POST['email'];
$comments = $_POST['comments'];
$to = "[EMAIL="thex-faders@fsmail.net"]thex-faders@fsmail.net[/EMAIL]"; //Please change this to your e-mail address
$message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email";
//check to make sure all form elements were filled in
if ($name == "") {
    echo 'You must provide your name to contact us. Please click the back, and try again';
 $formgood = "f";
}
if ($email == "") {
    echo 'We require an e-mail address in order for us to respond. Please go back and try again.';
 $formgood = "f";
}
if ($comments == "") {
    echo 'You must provide comments in order to submit this form. Please click back, and try again.';
 $formgood = "f";
}
if ($telephone == "") {
    echo 'You must provide comments in order to submit this form. Please click back, and try again.';
 $formgood = "f";
}
if ($formgood == "t") {
    if(mail($to, "A contact us form has been submitted by $name", $message, $telephone, "From: $email\n")) {
   echo 'Thank you for submitting this form. We will review your comments and contact you shortly. <br><br> Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.';
}
 }
else {
         
echo '<br>Copyright ' . date(Y) . ' ETYN Corps. All rights reserved.';
}
?>

Not quite you don't place the telephone variable after the message variable you place it in the message variable. So the actual mail statement would not change. Your $message line at the beggining would change to something like this:

$message = "$name has submitted a contact form. \n\n $comments \n\n You can reply to $email \n Telephone: $telephone";

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.