Jump to content

Confused - Help php data to html table to be sent by mail()


mikeweb

Recommended Posts

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Corporate RMA Request Form - Submit Form</title>
<?
function sendForm()
{

//form vars
$newLine = "<br>";

//populate vars from post
$txtDate = $_POST["txtDate"];
$SYSN["theDate"] = $_POST["txtDate"];
$txtAgentName=$_POST["txtAgentName"];
$txtBanNum=$_POST["txtBanNum"];
$txtWirelessNum=$_POST["txtWirelessNum"];
$txtCustomerName=$_POST["txtCustomerName"];
$txtTicketNum=$_POST["txtTicketNum"];
$txtContactName=$_POST["txtContactName"];
$txtContactPhone=$_POST["txtContactPhone"];
$txtContactEmail=$_POST["txtContactEmail"];
$drpWirelessDevice=$_POST["drpWirelessDevice"];
$txtPinNum=$_POST["txtPinNum"];
$txtIMEI=$_POST["txtIMEI"];
$txtSimNum=$_POST["txtSimNum"];
$txtDefectNote=$_POST["txtDefectNote"];
$txtShipAttentionTo=$_POST["txtShipAttentionTo"];
$txtShipCompanyName=$_POST["txtShipCompanyName"];
$txtShipAddress=$_POST["txtShipAddress"];
$txtShipCity=$_POST["txtShipCity"];
$txtShipProv=$_POST["txtShipProv"];
$txtShipPostal=$_POST["txtShipPostal"];


$formData='
<table width="400" border="1" cellspacing="1" bordercolor="#D40139">
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Corporate RMA Request form</span></b>
</td>
    </tr>
  <tr>
    <td>
Date: <?php "$txtDate; ?><br>
TicketNum <?php echo $txtTicketNum; ?>
</td>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Customer Information</span></b>
</td>
    </tr>
  <tr>
    <td>
Customer Information<br>
Ban: <?php echo $txtBanNum; ?>
txtWirelessNum <?php echo $txtWirelessNum; ?><br>
txtCustomerName <?php echo $txtCustomerName; ?>
</td>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Contact Information</span></b>
</td>
    </tr>
  <tr>
    <td>
txtContactName <?php echo $txtContactName; ?>
txtContactPhone <?php echo $txtContactPhone; ?><br>
txtContactEmail <?php echo $txtContactEmail; ?>
</td>
  </tr>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Device Information</span></b>
</td>
    </tr>
  <tr>
    <td>
txtPinNum <?php echo $txtPinNum; ?>
txtIMEI <?php echo $txtIMEI; ?><br>
txtSimNum <?php echo $txtSimNum; ?>
</td>
  </tr>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Defect Information</span></b>
</td>
    </tr>
  <tr>
    <td>
<textarea name="txtDefectNote" cols="35" rows="6">"<?php echo $txtDefectNote ?>"</textarea>
</td>
  </tr>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Shipping Information</span></b>
</td>
    </tr>
  <tr>
    <td>
txtShipAttentionTo <?php echo $txtShipAttentionTo; ?><br>
txtShipCompanyName <?php echo $txtShipCompanyName; ?><br>
txtShipAddress <?php echo $txtShipAddress; ?><br>
txtCityProvPostal <?php echo $txtShipCity; ?>
</td>
  </tr>
</table>
';

//populate email vars
echo $newLine;
$to = "[email protected]";
//$headers = "From: [email protected]";
$headers = "From: [email protected]\r\nContent-type: text/html\r\n";
$subject = "Corporate RMA request form - ".$txtTicketNum;
$body=$formData;

echo "To: ".$to.$newLine;
echo "From: ".$headers.$newLine;
echo "Subject: ".$subject.$newLine.$newLine;
echo "Body: ".$newLine.$body.$newLine;

if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}


//function end
}


//Send the completed form
sendForm();
?>
I'm not really sure why you've specified a variable (incorrectly) for a new line in some places and used the proper newline / carriage return characters in others.

You're also echoing your message headers to the screen and not actually putting them in a mail function.

There's a couple of problems to get you going, fairly sure there'll be more but I just had a quick scan through and theyre the things that leapt out at me.

Could you correct those, test and then provide a little more detail as to the problem you're getting as just posting some code with no further explanation doesn't give would-be helpers much info.
sorry guys ... my message somehow got deleted...

I'm having trouble getting my php variables to show up in the table that I'm trying to email using mail(). I've done alot of research on the web but no good clues. Any suggestions

p.s. newLine=<<br>> but doesn't show up in my post as it's html as well
[quote author=mikeweb link=topic=105339.msg420687#msg420687 date=1156343364]
sorry guys ... my message somehow got deleted...

I'm having trouble getting my php variables to show up in the table that I'm trying to email using mail(). I've done alot of research on the web but no good clues. Any suggestions

p.s. newLine=<<br>> but doesn't show up in my post as it's html as well
[/quote]

My bad, I think I misread a bit of the way your code works...teach me to scan too quickly...I'll have a deeper look (with a bit more care)
*Bump

my vars show up as (for example) $txtDate ... instead of the date that was sent

I just figured out to properly post my code. Here it is...

[code]
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Corporate RMA Request Form - Submit Form</title>

<?php
function sendForm()
{

//form vars
$newLine = "<br>";

//populate vars from post
$txtDate = $_POST["txtDate"];
$SYSN["theDate"] = $_POST["txtDate"];
$txtAgentName=$_POST["txtAgentName"];
$txtBanNum=$_POST["txtBanNum"];
$txtWirelessNum=$_POST["txtWirelessNum"];
$txtCustomerName=$_POST["txtCustomerName"];
$txtTicketNum=$_POST["txtTicketNum"];
$txtContactName=$_POST["txtContactName"];
$txtContactPhone=$_POST["txtContactPhone"];
$txtContactEmail=$_POST["txtContactEmail"];
$drpWirelessDevice=$_POST["drpWirelessDevice"];
$txtPinNum=$_POST["txtPinNum"];
$txtIMEI=$_POST["txtIMEI"];
$txtSimNum=$_POST["txtSimNum"];
$txtDefectNote=$_POST["txtDefectNote"];
$txtShipAttentionTo=$_POST["txtShipAttentionTo"];
$txtShipCompanyName=$_POST["txtShipCompanyName"];
$txtShipAddress=$_POST["txtShipAddress"];
$txtShipCity=$_POST["txtShipCity"];
$txtShipProv=$_POST["txtShipProv"];
$txtShipPostal=$_POST["txtShipPostal"];


$formData='
<table width="400" border="1" cellspacing="1" bordercolor="#D40139">
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Corporate RMA Request form</span></b>
</td>
    </tr>
  <tr>
    <td>
Date: <?php= echo "$txtDate; ?><br>
TicketNum <?php echo $txtTicketNum; ?>
</td>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Customer Information</span></b>
</td>
    </tr>
  <tr>
    <td>
Customer Information<br>
Ban: <?php echo $txtBanNum; ?>
txtWirelessNum <?php echo $txtWirelessNum; ?><br>
txtCustomerName <?php echo $txtCustomerName; ?>
</td>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Contact Information</span></b>
</td>
    </tr>
  <tr>
    <td>
txtContactName <?php echo $txtContactName; ?>
txtContactPhone <?php echo $txtContactPhone; ?><br>
txtContactEmail <?php echo $txtContactEmail; ?>
</td>
  </tr>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Device Information</span></b>
</td>
    </tr>
  <tr>
    <td>
txtPinNum <?php echo $txtPinNum; ?>
txtIMEI <?php echo $txtIMEI; ?><br>
txtSimNum <?php echo $txtSimNum; ?>
</td>
  </tr>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Defect Information</span></b>
</td>
    </tr>
  <tr>
    <td>
<textarea name="txtDefectNote" cols="35" rows="6">"<?php echo $txtDefectNote ?>"</textarea>
</td>
  </tr>
    <tr>
<td width=300 valign=top bgcolor="#D40139">
<b><span style="font-size:9.0pt;color:white">Shipping Information</span></b>
</td>
    </tr>
  <tr>
    <td>
txtShipAttentionTo <?php echo $txtShipAttentionTo; ?><br>
txtShipCompanyName <?php echo $txtShipCompanyName; ?><br>
txtShipAddress <?php echo $txtShipAddress; ?><br>
txtCityProvPostal <?php echo $txtShipCity; ?>
</td>
  </tr>
</table>
';

//populate email vars
echo $newLine;
$to = "[email protected]";
//$headers = "From: [email protected]";
$headers = "From: [email protected]\r\nContent-type: text/html\r\n";
$subject = "Corporate RMAA request form - ".$txtTicketNum;
$body=$formData;

echo "To: ".$to.$newLine;
echo "From: ".$headers.$newLine;
echo "Subject: ".$subject.$newLine.$newLine;
echo "Body: ".$newLine.$body.$newLine;

if (mail($to, $subject, $body, $headers)) {
  echo("<p>Message successfully sent!</p>");
} else {
  echo("<p>Message delivery failed...</p>");
}


}//function end


//Send the completed form
sendForm();
?>
[/code]
Change all of your vars in the email from <?php echo $varname; ?> to ' . $varname . ':

[code]Customer Information<br>
Ban: <?php echo $txtBanNum; ?>
txtWirelessNum <?php echo $txtWirelessNum; ?><br>
txtCustomerName <?php echo $txtCustomerName; ?>[/code]

should be:

[code]Customer Information<br>
Ban: ' . $txtBanNum . '
txtWirelessNum ' . $txtWirelessNum . '<br>
txtCustomerName ' . $txtCustomerName . '[/code]
You are a champion and a scholar sir ! That worked just fine.
I was down to one hair left on my head.

THANK YOU !

[quote author=hitman6003 link=topic=105339.msg420803#msg420803 date=1156350453]
Change all of your vars in the email from <?php echo $varname; ?> to ' . $varname . ':

[code]Customer Information<br>
Ban: <?php echo $txtBanNum; ?>
txtWirelessNum <?php echo $txtWirelessNum; ?><br>
txtCustomerName <?php echo $txtCustomerName; ?>[/code]

should be:

[code]Customer Information<br>
Ban: ' . $txtBanNum . '
txtWirelessNum ' . $txtWirelessNum . '<br>
txtCustomerName ' . $txtCustomerName . '[/code]
[/quote]

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.