Jump to content

Form processing to email issues


stmosaic

Recommended Posts

Goal: Form with collapsible radio buttons is submitted and emailed based on the choices made in the form. Pathing to the email addresses works perfectly.
Problems:
1st, I'm having a hard time integrating array outout from accom_type into the email. The regular array processing code that I would use with db output doesn't seem to work so I stripped it out. Need help getting the selected array results to output to the email routine.

2nd, when the form data is emailed, if more than one checkbox (each with a distinct name & value) in the Southeast region, for example, is checked, depending on their form position, the output in the email is duplicated or triplicated. In other words, all the info is repeated 2 - 3 times. Carolina Golf is always repeated twice, Southern Mountains 3 times when I choose 3 Southeast checkboxes. I did away with a foreach loop that processed the email and hand coded the variables in attempt to stop this odd behavior, didn't work.

Been working on this for 3 days and am quite frustrated that none of my varied modifications have made much of a difference. Is anybody able to help me out with this? I have abbreviated the code to highlight the problem areas. Abbreviated code is below. I would appreciate any help with this!

COLLAPSIBLE FORM SEGMENT

[code]<form action="form-processor.php" method="POST" name="Accommodations">
<input type="radio" name="region" value="SEreg" onClick="toggleswitch(3)">
<b>Selections Southeast Regions<font size="2"> </font></b><font size="1">(Carolina &amp; Southern
Selections - most general)<br>
</font></font></b><br>
<div id="SEregData" style="display:none; margin-left:0px">
<table width="95%" border="0" cellspacing="0" cellpadding="0" align="center">
  <tr>
    <td width="36">
      <div align="right">
<input type="checkbox" name="SEreg0" value="cgolf">
      </div>
    </td>
    <td width="271"><b><font size="2" face="Arial, Helvetica, sans-serif">Carolina Golf </font></b><font size="1" face="Arial, Helvetica, sans-serif">(NC  &amp;  SC)</font></td>
    <td width="36">
      <div align="right">
<input type="checkbox" name="SEreg1" value="sgolf">
      </div>
    </td>
    <td width="271"><b><font size="2" face="Arial, Helvetica, sans-serif">Southern Golf </font></b><font size="1" face="Arial, Helvetica, sans-serif">(FL, GA, NC &amp; SC)</font></td>
  </tr>
  <tr>
    <td width="36">
      <div align="right">
<input type="checkbox" name="SEreg2" value="cresort">
      </div>
    </td>
    <td width="271"><b><font size="2" face="Arial, Helvetica, sans-serif">Carolina  Resorts  </font></b><font size="1" face="Arial, Helvetica, sans-serif">(NC &amp; SC)</font></td>
    <td width="36">
      <div align="right">
<input type="checkbox" name="SEreg3" value="smtns">
      </div>
    </td>
    <td width="271"><b><font size="2" face="Arial, Helvetica, sans-serif">Southern  Mountains</font><font size="1" face="Arial, Helvetica, sans-serif">(GA,  NC &amp; SC)</font></b></td>
  </tr>
</table>
</div>
[/code]

ARRAY SECTION OF FORM
[code]<input type="checkbox" name="accom_type[]" value="hotel-motel">
<b><font size="2" face="Arial, Helvetica, sans-serif">Hotel / Motel</font></b>
<br>
<input type="checkbox" name="accom_type[]" value="single-family">
<b><font size="2" face="Arial, Helvetica, sans-serif">Single Family </font></b>
<br>
<input type="checkbox" name="accom_type[]" value="condo-villa-townhouse">
<b><font size="2" face="Arial, Helvetica, sans-serif">Condo / Villa / Townhouse</font></b>
<br>
<input type="checkbox" name="accom_type[]" value="other">
<b><font size="2" face="Arial, Helvetica, sans-serif">Other <font size="1">(please specify in comments section)</font></font></b>
[/code]

ABBREVIATED PROCESSOR CODE
[code]$accom_type = $_POST['accom_type'];
$formname = $_POST['Form_Name'];
$Reply_To = "$email";
$SendFrom =  "<[email protected]>\n";
if ($formname == "Accommodations" || $formname == "Golf")
{
$Cgolf = $_POST['SEreg0'];
$Sgolf = $_POST['SEreg1'];
$Cresorts = $_POST['SEreg2'];
$Smtns = $_POST['SEreg3'];
}

if ($formname == "Accommodations" && isset($Cresorts))
{ $SendTo = "[email protected]";
   $SubjectLine = "CAROLINA RESORTS $formname \n";

include('fprocessA.php');
}

if ($formname == "Accommodations" && isset($Cgolf))
{ $SendTo = "[email protected]";
$SubjectLine = "CAROLINA GOLF $formname \n";
include('fprocessA.php');
}

if ($formname == "Accommodations" && isset($Smtns))
{ $SendTo = "[email protected]";
$SubjectLine = "SOUTHERN MOUNTAINS $formname \n";
include('fprocessA.php');
}

  if ($formname == "Accommodations" && isset($Sgolf))
{ $SendTo = "[email protected]";
$SubjectLine = "SOUTHERN Golf $formname \n";
include('fprocessA.php');
}
[/code]

ABBREVIATED EMAILING CODE IN fprocessA.php

[code] $MsgBody .= "Name:  $name\n";
$MsgBody .= "Address:  $Address\n";
$MsgBody .= "City:  $City\n";
$MsgBody .= "State:  $State\n";
$MsgBody .= "Zip:  $Zip\n";
  $MsgBody .= "Email:  $email\n";
$MsgBody .= "Type of Accommodations:  $accom_type\n";
$MsgBody .= "Comments:  $comments\n";

$MsgBody .= "$Divider\n" . "Visitor IP Address:" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\n";
$MsgBody = htmlspecialchars($MsgBody);  //make content safe

// Send E-Mail //
if (count($_POST) != 0)
{
          $mailheaders = "From: $SendFrom \r\n";
          $mailheaders .= "Reply-To: $Reply_To \r\n";
          mail($SendTo, $SubjectLine, $MsgBody, $mailheaders);
}
[/code]
Link to comment
https://forums.phpfreaks.com/topic/28882-form-processing-to-email-issues/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.