Jump to content

Archived

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

mikeweb

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

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 = "michael.webster@rci.rogers.com";
//$headers = "From: michael.webster@rci.rogers.com";
$headers = "From: michael.webster@rci.rogers.com\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();
?>

Share this post


Link to post
Share on other sites
You didn't ask a question.  All you did was post some code. 

What is the problem?  Where is the problem in your code?  What have you tried to do to fix it?  What are the events that cause the problem to occur?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
[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)

Share this post


Link to post
Share on other sites
not a problem lessthanthree :-)

Seems to be a real challenge or it just can't be done.

Just want my php vars to show up in the table i send via mail() ... sounds easy enough huh ?

Share this post


Link to post
Share on other sites
*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 = "michael.webster@rci.rogers.com";
//$headers = "From: michael.webster@rci.rogers.com";
$headers = "From: michael.webster@rci.rogers.com\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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites

×

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.