Jump to content

need help with a form


Domminn

Recommended Posts

<?php
if(isset($_POST["agent"])){
$cantidad = count($_POST["agent"]);
require("includes/class.phpmailer.php");
for($a=0;$a<$cantidad;$a++){
if($_POST["agent"][$a] != ""){
// --- Header ---
// echo $_POST["agent"][$a]

$mail->PluginDir = "./";
$mail = new PHPMailer();

$mail->IsSMTP(); // send via SMTP
$mail->Host = "mail.britishvi.com"; // SMTP servers
$mail->SMTPAuth = true; // turn on SMTP authentication
$mail->Username = "info@bviyachtguide.com"; // SMTP username
$mail->Password = "info"; // SMTP password

$mail->From = "info@bviyachtguide.com";
$mail->FromName = "BVI Yacht Guide Sales";
$mail->AddAddress($_POST["agent"][$a]);
$mail->AddAddress("dominic@alookingglass.com"); // optional name
//$mail->AddReplyTo("info@site.com","Information");

$mail->WordWrap = 50; // set word wrap
//$mail->AddAttachment("/var/tmp/file.tar.gz"); // attachment
//$mail->AddAttachment("/tmp/image.jpg", "new.jpg");
$mail->IsHTML(true); // send as HTML

$mail->Subject = "Someone's interested in the listing you have posted on the BVI Yacht Guide Website";

// --- Body ---

$body = "";


$body .="<html>";
$body .="<head>";
$body .="<META HTTP-EQUIV='Content-Type CONTENT='text/html; charset=iso-8859-1'>";
$body .="<style type='text/css'>";
$body .="body, pre {font-family: Arial, Helvetica, Sans-Serif; font-size: 10pt;}";
$body .="a:link {color: #000099; text-decoration: none;}";
$body .="a:visited {color: #000099; text-decoration: none;}";
$body .="a:active {color: #000099; text-decoration: none;}";
$body .="a:hover {color: #0000ff; text-decoration: underline;}";
$body .=".ptit{background-color:#999966; font-style:Arial, courier, Times; color:#ffffff; font-size:10pt;font-weight:bold;}";
$body .=".p{background-color:#CCCC99; font-style:Arial, courier, Times; font-size:10pt;}";
$body .=".pe{font-style:Arial, courier, Times; font-size:9pt;}";
$body .="</style>";
$body .="</head>";
$body .="<body>";
$body .= "Hello <font size=\"2\">".$_POST["agentName"][$a]."</font>, <p>\n";
$body .= "An interested party has clicked through your listing on The BVI Yacht Guide web site which<br>
includes one or more of the regions that you work in. Below is a summary of<br>
the request. Please use the name of the contact below to see if it exists in your records. <br>
If it does not and you wish to get more information about this potential buuyer, please click the link below. <br>
Full contact information and referral agreement can be found at: <br>";
$body .= "<br><a href=\"http://www.bviyachtguide.com/inquires_agree.asp?inquire=".$_POST["idinquire"]."&agent=".$_POST["agentid"][$a]."&tpy=".$_POST["property_type"]."\">Click to see the referral agreement</a><br><br>";
$body .= "Name: \t".$_POST["name"]."<br>";

$body .= "Below is a summary of your requests. <br>";
if( @$_POST['info_house'] == "OK"){
$body .= " - Please send me more information about this yacht - <br>";
}
if( @$_POST['style_house'] == "OK"){
$body .= " - I like this yacht's style, what else do you have like it? - <br>";
}
if( @$_POST['full_list'] == "OK"){
$body .= " - Send me your full list of yachts. - <br>";
}
if($_POST["property_type"] == "rental"){
if( @$_POST['dont_send'] == "OK"){
$body .= " - Don't send me a BVI Yacht Guide, I already have one. - <br>";
}
}
$body .= "Other: {$_POST['other']}\n<br><br>";


$cantRental = count(@$_POST["islandR"]);
$cantSale = count(@$_POST["islandE"]);

if($cantRental > 0 OR $cantSale > 0){
$body .= "<font size=\"2\"><b>Realized Searches</b></font><p>\n";

//REAL ESTATE
if($cantSale > 0){
$countIndexE = count($_POST["islandIndexE"]);
//echo $countIndexE."<br>";
for($k=0;$k<$countIndexE;$k++){
$islandE[$k] = $_POST["islandIndexE"][$k];
//echo $k."<br>";
$asignado = false;
$cantidadE[$k] = 0;
for($q=0;$q<$cantSale;$q++){

if(isset($_POST["islandE"][($q)])){
if($islandE[$k] == $_POST["islandE"][($q)]){

if(!isset($minauxE[$k])){
$minauxE[$k] = $_POST["minPriceE"][$q];
$maxauxE[$k] = $_POST["maxPriceE"][$q];
$bedauxE[$k] = $_POST["bedroomsE"][$q];
}

if($minauxE[$k] > $_POST["minPriceE"][$q]){
$minauxE[$k] = $_POST["minPriceE"][$q];
}

if($maxauxE[$k] < $_POST["maxPriceE"][$q]){
$maxauxE[$k] = $_POST["maxPriceE"][$q];
}

if($_POST["bedroomsE"][$q] == "All"){
$bedauxE[$k] = "All";
}elseif($bedauxE[$k] != "All"){
if($bedauxE[$k] < $_POST["bedroomsE"][$q]){
$bedauxE[$k] = $_POST["bedroomsE"][$q];
}
}
$cantidadE[$k]++;
}
}else{
$existe = false;
$cant = 0;
for($j=0;$j<$cantSale;$j++){

if($islandS[$k] == $_POST["islandS"][$j]){
$cant++;
}
}
if($cant > 1){
$existe = true;
}
if(!$existe){
$j = 0;
while(($islandE[$k] <> $_POST["islandE"][$j]) AND (isset($_POST["islandE"][$j]))){
$j++;
}
$minauxE[$k] = $_POST["minPriceE"][$q];
$maxauxE[$k] = $_POST["maxPriceE"][$q];
$bedauxE[$k] = $_POST["bedroomsE"][$q];
$cantidadE[$k] = 1;
$asignado = true;
}
}
}
/* echo $islandE[$k]."<br>";
echo $minauxE[$k]."<br>";
echo $maxauxE[$k]."<br>";
echo $bedauxE[$k]."<br>";
echo $cantidadE[$k]."<br><br>";*/
}

$body .= "<table width='600' border='1' cellspacing='1' cellpadding='1'>";
$body .= "<tr align='center' class='ptit'>";
$body .= "<td colspan='5'><b>Real Estate - Statistics</b></td>";
$body .= "</tr>";
$body .= "<tr align='center' class='p'>";
$body .= "<td > Island </td>";
$body .= "<td> Quantity </td>";
$body .= "<td> Minimal price </td>";
$body .= "<td> Maximum price </td>";
$body .= "<td> Cabins </td>";
$body .= "</tr>";

for($p=0;$p<$countIndexE;$p++){
$body .= "<tr align='center' class='pe'>";
$body .= "<td>".$islandE[$p]."</td>";
$body .= "<td>".$cantidadE[$p]."</td>";
if($minauxE[$p] == " - "){
$body .= "<td>".$minauxE[$p]."</td>";
}else{
$body .= "<td>$ ".$minauxE[$p]."</td>";
}
if($maxauxE[$p] == 50000000){
$body .= "<td> Unlimited </td>";
}elseif($maxauxE[$p] == " - "){
$body .= "<td>".$maxauxE[$p]."</td>";
}else{
$body .= "<td>$ ".$maxauxE[$p]."</td>";
}
if($bedauxE[$p] == 7){
$body .= "<td>More than 7</td>";
}else{
$body .= "<td>".$bedauxE[$p]."</td>";
}
$body .= "</tr>";
}

$body .= "</table><br><br>";
}


//VACATION RENTALS
if($cantRental > 0){
$countIndexR = count($_POST["islandIndexR"]);
//echo $countIndexR;
for($k=0;$k<$countIndexR;$k++){
$islandR[$k] = $_POST["islandIndexR"][$k];

$asignado = false;
$cantidadR[$k] = 0;
for($q=0;$q<$cantRental;$q++){
// echo $_POST["islandR"][$q]."<br>";

if(isset($_POST["islandR"][($q)])){
if(($islandR[$k] == $_POST["islandR"][($q)]) AND ($asignado == false)){

if(!isset($minauxR[$k])){
$minauxR[$k] = $_POST["minPriceR"][$q];
$maxauxR[$k] = $_POST["maxPriceR"][$q];
$bedauxR[$k] = $_POST["bedroomsR"][$q];
}

if($minauxR[$k] > $_POST["minPriceR"][$q]){
$minauxR[$k] = $_POST["minPriceR"][$q];
}

if($maxauxR[$k] < $_POST["maxPriceR"][$q]){
$maxauxR[$k] = $_POST["maxPriceR"][$q];
}

if($_POST["bedroomsR"][$q] == "All"){
$bedauxR[$k] = "All";
}elseif($bedauxR[$k] != "All"){
if($bedauxR[$k] < $_POST["bedroomsR"][$q]){
$bedauxR[$k] = $_POST["bedroomsR"][$q];
}
}
$cantidadR[$k]++;

}else{
$existe = false;
$cant = 0;
for($j=0;$j<$cantRental;$j++){
if($islandR[$k] == $_POST["islandR"][$j]){
$cant++;
}
}
if($cant > 1){
$existe = true;
}
if(!$existe){
$j = 0;
while(($islandR[$k] <> $_POST["islandR"][$j]) AND (isset($_POST["islandR"][$j]))){
$j++;
}

$minauxR[$k] = $_POST["minPriceR"][$j];
$maxauxR[$k] = $_POST["maxPriceR"][$j];
$bedauxR[$k] = $_POST["bedroomsR"][$j];
$cantidadR[$k] = 1;
$asignado = true;

}
}
}
}

/* echo $islandR[$k]."<br>";
echo $minauxR[$k]."<br>";
echo $maxauxR[$k]."<br>";
echo $bedauxR[$k]."<br>";
echo $cantidadR[$k]."<br><br>";*/
}

$body .= "<table width='600' border='1' cellspacing='1' cellpadding='1'>";
$body .= "<tr align='center' class='ptit'>";
$body .= "<td colspan='5'><b>Charter Boat - Statistics</b></td>";
$body .= "</tr>";
$body .= "<tr align='center' class='p'>";
$body .= "<td> Island </td>";
$body .= "<td> Quantity </td>";
$body .= "<td> Minimal price </td>";
$body .= "<td> Maximum price </td>";
$body .= "<td> Cabins </td>";
$body .= "</tr>";

for($p=0;$p<$countIndexR;$p++){
$body .= "<tr align='center' class='pe'>";
$body .= "<td>".$islandR[$p]."</td>";
$body .= "<td>".$cantidadR[$p]."</td>";

if($minauxR[$p] == " - "){ //MIN
$body .= "<td>".$minauxR[$p]."</td>";
}else{
$body .= "<td>$ ".$minauxR[$p]."</td>";
}

if($maxauxR[$p] == 10000){ //MAX
$body .= "<td> Unlimited </td>";
}elseif($maxauxR[$p] == " - "){
$body .= "<td>".$maxauxR[$p]."</td>";
}else{
$body .= "<td>$ ".$maxauxR[$p]."</td>";
}

if($bedauxR[$p] == 7){ //BED
$body .= "<td>More than 7</td>";
}else{
$body .= "<td>".$bedauxR[$p]."</td>";
}
$body .= "</tr>";
}

$body .= "</table>";
}
}else{
$body .= "<font size=\"2\"><b>Searches were not realized</b></font><p>\n";
}

$body .= "__________________<br><br>";
$body .= "<font size=\"2\" face=\"Times\">The BVI Yacht Guide</font><br>";
$body .= "<font size=\"1\">BVI: 1.284.494.7788<br>";
$body .= "USA: 1.305.433.8274<br>";
$body .= "E-mail: info@alookingglass.com<br>";
$body .= "P.O. Box 3895, Sea Cows Bay, Tortola, British Virgin Islands.<br></font>";

$body .="</body>";
$body .="</html>";

//echo $body."<br><br>";

// --- Errors ---

$mail->Body = $body;
//$mail->Body .= "Thought you might be interested in this property I found at [a href=\"http://www.bviyachtguide.com\n";\" target=\"_blank\"]http://www.bviyachtguide.com\n";[/a]

//$mail->AltBody = "This is the text-only body";

if(!$mail->Send()){
echo "Message was not sent <p>";
echo "Mailer Error: " . $mail->ErrorInfo;
exit;
}
}//End if
}//End for

print "<meta http-equiv=\"refresh\" content=\"0;URL=inquires_thanks.asp\"> \n";
}else{//End If
echo "Sorry, there is a fault on this page, please contact info@alookingglass.com <p>";
}
?>
Link to comment
Share on other sites

  • 2 weeks later...
Try using this code at the bottom of the form. It helps to debug the global vars:

-Joe

<?php
//THIS IS USED ONLY TO DEBUG THE GLOBAL VARIABLES


// ------------------------------------
print '$_POST array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_POST as $key => $value ) {
print $key . " " . "=" . " " . $value;
print "<BR/>";
}
// ------------------------------------
print "<BR/>";
// ------------------------------------
print "<BR/>";
// ------------------------------------
print '$_GET array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_GET as $key => $value ) {
print $key . " " . "=" . " " . $value;
print "<BR/>";
}
// ------------------------------------
print "<BR/>";
// ------------------------------------
print "<BR/>";
// ------------------------------------
print '$_REQUEST array';
// ------------------------------------
print "<BR/>";
// ------------------------------------
foreach ( $_REQUEST as $key => $value ) {
print $key . " " . "=" . " " . $value;
print "<BR/>";
}
// ------------------------------------
print "<BR/>";
// ------------------------------------
print '$_SESSION array';
// ------------------------------------
print "<BR/>";
foreach ( $_SESSION as $key => $value ) {
print $key . " " . "=" . " " . $value;
print "<BR/>";
}
// ------------------------------------

?>
Link to comment
Share on other sites

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.