Jump to content


Photo

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


  • Please log in to reply
8 replies to this topic

#1 mikeweb

mikeweb
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 August 2006 - 02:15 PM

<!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();
?>

#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 23 August 2006 - 02:18 PM

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?

#3 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 23 August 2006 - 02:19 PM

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.
call me a safe bet, i'm betting i'm not

#4 mikeweb

mikeweb
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 August 2006 - 02:29 PM

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

#5 lessthanthree

lessthanthree
  • Members
  • PipPipPip
  • Advanced Member
  • 85 posts
  • LocationUK

Posted 23 August 2006 - 02:48 PM

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


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)
call me a safe bet, i'm betting i'm not

#6 mikeweb

mikeweb
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 August 2006 - 02:59 PM

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 ?

#7 mikeweb

mikeweb
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 August 2006 - 03:45 PM

*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...

<!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();
?>


#8 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 23 August 2006 - 04:27 PM

Change all of your vars in the email from <?php echo $varname; ?> to ' . $varname . ':

Customer Information<br>
		Ban: <?php echo $txtBanNum; ?>
		txtWirelessNum <?php echo $txtWirelessNum; ?><br>
		txtCustomerName <?php echo $txtCustomerName; ?>

should be:

Customer Information<br>
		Ban: ' . $txtBanNum . '
		txtWirelessNum ' . $txtWirelessNum . '<br>
		txtCustomerName ' . $txtCustomerName . '


#9 mikeweb

mikeweb
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 23 August 2006 - 04:33 PM

You are a champion and a scholar sir ! That worked just fine.
I was down to one hair left on my head.

THANK YOU !

Change all of your vars in the email from <?php echo $varname; ?> to ' . $varname . ':

Customer Information<br>
		Ban: <?php echo $txtBanNum; ?>
		txtWirelessNum <?php echo $txtWirelessNum; ?><br>
		txtCustomerName <?php echo $txtCustomerName; ?>

should be:

Customer Information<br>
		Ban: ' . $txtBanNum . '
		txtWirelessNum ' . $txtWirelessNum . '<br>
		txtCustomerName ' . $txtCustomerName . '






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users