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 = "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();
?>
Link to comment
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.
Link to comment
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
Link to comment
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)
Link to comment
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]
Link to comment
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]
Link to comment
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]
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.