Jump to content

Recommended Posts

guys,  ???

i really really need your help on this.
i have two page form. eform.php and sendmail.php

the eform is for the form that needs to be filled up and the sendmail is
the page that verifies and sends the information from the form via email.
below is my code for the eform.php
[code]<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td><table width="641" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td width="641">&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td align="center"><form id="form1" name="form1" method="post" action="sendmail.php">
          <table width="617" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td width="4">&nbsp;</td>
              <td width="95" valign="top"><span  class="item1">Salutation:</span></td>
              <td width="10">&nbsp;</td>
              <td width="332" valign="top">
                <select name="salutation" class="item1f">
<option value="Mr." selected="selected">Mr.</option>
<option value="Mr.">Ms.</option>
<option value="Mr.">Mrs.</option>
</select></td>
              <td width="182">&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span  class="item1">Surname:</span><span class="item2">*</span></td>
              <td>&nbsp;</td>
              <td valign="top">
                <input name="surname" type="text" class="item1f" /></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span  class="item1">Firstname:<span class="item2">*</span></span></td>
              <td>&nbsp;</td>
              <td valign="top"><input name="firstname" type="text" class="item1f" /></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span class="item1">E-mail: </span><span class="item2">*</span> </td>
              <td>&nbsp;</td>
              <td valign="top"><input name="email" type="text" class="item1f" /></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span  class="item1">Telephone: </span><span class="item2">*</span></td>
              <td>&nbsp;</td>
              <td valign="top"><input name="phone" type="text" class="item1f" /></td>
              <td class="item2">* please include country and area code </td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top" class="item1">Fax: </td>
              <td>&nbsp;</td>
              <td valign="top"><input name="fax" type="text" class="item1f" /></td>
              <td class="item2">* please include country and area code</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top">&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span  class="item1">Address:<span class="item2">*</span></span></td>
              <td>&nbsp;</td>
              <td>
                <textarea name="address" cols="30" rows="5" class="item1f"></textarea>            </td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span class="item1">Country:</span></td>
              <td>&nbsp;</td>
              <td><SELECT NAME="country" size="1" class="item1f">
                <option value="#" selected>Select your Country: </option>
                <option value="#">- - - - - - - - - - - - - - - - - - - - - - - -</option>
                <option value="Afghanistan">Afghanistan </option>
              </SELECT></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span class="item1">Resortl:</span></td>
              <td>&nbsp;</td>
              <td><select name="resort" class="item1f">
  <option value="Banyan Tree Bahrain">Banyan Tree Bahrain</option>
              </select></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top"><span  class="item1"> Activities:</span></td>
              <td>&nbsp;</td>
              <td colspan="2"><table width="513" border="0" cellspacing="0" cellpadding="0">
                <tr>
                  <td width="27" rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item1"></td>
                  <td width="476"><span class="item3">&#8226; Night snorkeling on the house reef</span></td>
                </tr>
                <tr>
                  <td class="item2">&nbsp;&nbsp;&nbsp;Price: 5USD </td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item2"></td>
                  <td><span class="item3">&#8226; Dawn snorkeling on the house reef</span> </td>
                </tr>
                <tr>
                  <td><span class="item2">&nbsp;&nbsp;&nbsp;Price: 5USD </span></td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item3"></td>
                  <td class="item3"> &#8226; Coral planting in the lagoon </td>
                </tr>
                <tr>
                  <td class="item3"><span class="item2">&nbsp;&nbsp;&nbsp;Price: 5USD </span></td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item4"></td>
                  <td class="item3">&#8226; Introduction to the biology, ecology and conservation of reef sharks and sea turtles: tour of research </td>
                </tr>
                <tr>
                  <td class="item3"><span class="item2">&nbsp;&nbsp;&nbsp;Price: 5USD </span></td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item5"></td>
                  <td class="item3">&#8226; Reef Survey - using internationally accepted methods and criteria, a comparative survey of the house </td>
                </tr>
                <tr>
                  <td class="item3"><span class="item2">&nbsp;&nbsp;&nbsp;Price: 24USD </span></td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item6"></td>
                  <td class="item3">&#8226; Tree Planting: planting of coconut palms on beach </td>
                </tr>
                <tr>
                  <td class="item3"><span class="item2">&nbsp;&nbsp;&nbsp;Price: 5USD </span></td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item7"></td>
                  <td class="item3">&#8226; Bird nesting box construction </td>
                </tr>
                <tr>
                  <td class="item3"><span class="item2">&nbsp;&nbsp;&nbsp;Price: 5USD </span></td>
                </tr>
                <tr>
                  <td rowspan="2" valign="top"><input name="checkbox" type="checkbox" class="item1f" value="item8"></td>
                  <td class="item3">&#8226; Dolfin cruise with Marine biology guide </td>
                </tr>
                <tr>
                  <td class="item3"><span class="item2">&nbsp;&nbsp;&nbsp;Price: 80USD </span></td>
                </tr>
              </table></td>
              </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td class="item1">Persons:</td>
              <td>&nbsp;</td>
              <td valign="top"><input name="adult" type="text" class="item1f" size="4" maxlength="3" />                &nbsp;<span class="item1">Adult</span> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                <input name="child" type="text" class="item1f" size="4" maxlength="3" />
                <span class="item1">Child</span></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td class="item1">Arrival Date: </td>
              <td>&nbsp;</td>
              <td><select name="day" class="item1f">
                <option value="01">01</option>
              </select>
                <select name="month" class="item1f">
                  <option value="January 2007">January 2007</option>
                </select></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td valign="top" class="item1">Special Request: </td>
              <td>&nbsp;</td>
              <td><textarea name="special" cols="30" rows="5" class="item1f"></textarea></td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>
                <input name="Submit" type="submit" class="item1f" value="Submit" />              </td>
              <td>&nbsp;</td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
              <td>&nbsp;</td>
            </tr>
          </table>
                  </form>
          </td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
  </tr>
</table>
[/code]

and this is the code for my sendmail.php

[code]<?php

$salutation = $_POST['salutation'];
$surname = $_POST['surname'];
$firstname = $_POST['firstname'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$fax = $_POST['fax'];
$address = $_POST['address'];
$country = $_POST['country'];
$resort = $_POST['resort'];
$adult = $_POST['adult'];
$child = $_POST['child'];
$day = $_POST['day'];
$month = $_POST['month'];
$special = $_POST['special'];

if((!$surname) || (!$firstname) || (!$email) || (!$phone) || (!$address)) {
    echo '<script language=javascript> alert("You did not submit the following required information!");</script>';
if(!$surname){
    echo '<script language=javascript> alert("Surname is required");top.location = "eform.php";</script>';
}
if(!$firstname){
echo '<script language=javascript> alert("Firstname is required");top.location = "eform.php";</script>';
}
if(!email_is_valid($email)) {
echo '<script language=javascript> alert("Please use a valid Email Address");top.location = "eform.php";</script>';
}
if(!$phone){
echo '<script language=javascript> alert("Phone is required");top.location = "eform.php";</script>';
}
if(!$address){
    echo '<script language=javascript> alert("Address is required");top.location = "eform.php";</script>';
}

exit();

//this will put your options in a list...so if 2, 4, and 5 are selected it will print "2, 4, 5"
$checkbox = implode(",""<br>", $_POST['checkbox']);

$Message = "";
$Message .= "An Earth Day Participate email from: $salutation $firstname $surname\n";
$Message .= "Telephone Number: $phone\n";
$Message .= "Fax Number: $fax\n";
$Message .= "Email Address: $email\n";
$ip = getenv("REMOTE_ADDR");
$Message .="IP address:".$ip."\n";
$Message .= "Address: $address , $country \n";
$Message .= "Resort Location: $resort\n";
$Message .= "Activity Selected: $checkbox\n";
$Message .= "Number of Adults: $adult\n";
$Message .= "Number of Kids: $child\n";
$Message .= "Arrival Date: $day $month\n";
$Message .= "\n\n";
$Message .= "Special Request: $special\n";



$Header = $email;
$To = "reservation@banyantree.com";
$Subject = "Earth Day Participation";

// mail($To,$Subject,$Message,"From: $Header","-f $EmailAdd"); last parameter might not be supported
mail($To,$Subject,$Message,"From: $Header");

echo '<script language=javascript> alert("Your Participation Request has been submitter. Thank you!");top.location = "eform.php";</script>';

function email_is_valid ($email) {
    if(eregi("^[0-9a-z_]([-_.]?[0-9a-z])*@[0-9a-z]([-.]?[0-9a-z])*\\.[a-z]{2,3}$", $email, $check)){
      if ( getmxrr(substr(strstr($check[0], '@'), 1), $validate_email_temp) ) {
        return TRUE;
      }
      // THIS WILL CATCH DNSs THAT ARE NOT MX.
      if(checkdnsrr(substr(strstr($check[0], '@'), 1),"ANY")){
        return TRUE;
      }
    }
    return FALSE;
  }
?>


[/code]

hoping for your help on this. thanks a lot!!!
Link to comment
https://forums.phpfreaks.com/topic/35455-need-help-on-my-form-with-check-boxes/
Share on other sites

by the way, my problem here is
when i am about to send the form
it just goes to the sendmail.php
nothing esle is happening.

the pop up that should appear telling that the message has been sent
is not appearing

i dont get any emails too.

need help please. thanks!
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.