Page 1 of 1

Mail problem

Posted: Thu Jan 29, 2004 3:27 pm
by Robbie1974
This is the javascript code i'm using to display items in my shopping cart in my order.php.

Code: Select all

function showItems() {
                index = document.cookie.indexOf("TheBasket");
                countbegin = (document.cookie.indexOf("=", index) + 1);
                countend = document.cookie.indexOf(";", index);
                if (countend == -1) {
                            countend = document.cookie.length;
                }
                fulllist = document.cookie.substring(countbegin, countend);
                subtotal = 0;
                subweight = 0;
                document.writeln('<table cellpadding="2" cellspacing="1" border="0">');

                document.writeln('<TR><TD BGCOLOR="#B3B3B3"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_qty ?></b></FONT></TD><TD  BGCOLOR="#B3B3B3"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_code_no ?></b></FONT></TD><TD BGCOLOR="#B3B3B3"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_item ?></b></FONT></TD><TD BGCOLOR="#B3B3B3"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_price ?>&nbsp;<?php echo $txt_currency ?></b></FONT></TD><td BGCOLOR="#B3B3B3"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b><?php echo $txt_sub_total ?></b></FONT></td></TR>');
                itemlist = 0;
                for (var i = 0; i <= fulllist.length; i++) &#123;
                        if (fulllist.substring(i,i+1) == '&#1111;') &#123;
                                thisitem = 1;
                                itemstart = i+1;
                        &#125; else if (fulllist.substring(i,i+1) == ']') &#123;
                                itemend = i;
                                thequantity = fulllist.substring(itemstart, itemend);
                                itemtotal = 0;
                                itemtotal = (eval(theprice*thequantity));
                                temptotal = itemtotal * 100;
                                subtotal = subtotal + itemtotal;
                                itemlist=itemlist+1;
document.write('<tr><td align=middle BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+thequantity+'</FONT></td>');
                                document.writeln('<td BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><a href=prod_show.php?code_no='+thenumber+'>'+thenumber+'</A></FONT></td><td align=left BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><a href=prod_show.php?code_no='+thenumber+'>'+theitem+'</A></FONT></td><td align=right BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+theprice+'</FONT></td><td align=right BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+alterError(itemtotal)+'</FONT></td></tr>');

                        &#125; else if (fulllist.substring(i,i+1) == '|') &#123;
                                if (thisitem==1) theitem = fulllist.substring(itemstart, i);
                                if (thisitem==2) theprice = fulllist.substring(itemstart, i);
                                if (thisitem==3) thenumber = fulllist.substring(itemstart, i);
                                if (thisitem==4) theweight = fulllist.substring(itemstart, i);
                                thisitem++;
                                itemstart=i+1;
                        &#125;
                &#125;

                totprice = (Math.round(subtotal*100)/100);
              shipping = <?php echo $add_freight ?>;
                totalcost = (totprice+shipping);
            tax = (Math.round(totalcost*<?php echo $add_tax ?>)/100);


<?
echo ("document.writeln('<tr><td align=right BGCOLOR="#B3B3B3" colspan=4><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>$txt_sub_total</b></FONT></td><td align=right BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans serif">'+alterError(totprice)+'</FONT></td></tr>');") ;
?>

<?
echo ("document.writeln('<tr><td align=right BGCOLOR="#B3B3B3" colspan=4><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>$txt_shipping</b></FONT></td><td align=right BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans serif">'+alterError(shipping)+'</FONT></td></tr>');") ;
?>

<?
if( $add_tax  >"0") &#123;
echo ("document.writeln('<tr><td align=right BGCOLOR="#B3B3B3" colspan=4><font size="-2" face="Verdana, Arial, Helvetica, sans-serif"><b>$txt_tax</b></FONT></td><td align=right BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+alterError(tax)+'</FONT></td></tr>');") ;
&#125;
?>

                document.writeln('<tr><td align=right BGCOLOR="#B3B3B3" colspan=4><font size="-2" face="Verdana, Arial,                 Helvetica, sans-serif"><b><?php echo $txt_total ?>&nbsp;<?php echo $txt_currency ?></b></FONT></td><td align=right BGCOLOR="#D9D9D9"><font size="-2" face="Verdana, Arial, Helvetica, sans-serif">'+alterError(totalcost+tax)+'</FONT></td></tr>');
                document.writeln('<INPUT TYPE="hidden" NAME="total" VALUE="'+alterError(totalcost+tax)+'" SIZE="40">');



                document.writeln('</TABLE>');

        &#125;

</script>
This is my mail page:

Code: Select all

<?php


// generates cart id number
$cart_id = date("ymjHis");



// required variables
require("config.php");

$message ="IP: $REMOTE_ADDR  Host: $REMOTE_HOST

Invoice - Order Number $cart_id

$email
$company
$name
$address
$address2
$city
$state
$zip
$country
$phone

$comment

Total $txt_currency:  $total

Order:

$txt_code_no $txt_item

";



mail("$receipt,$email", "Online bestelling", "$message", "From:$receipt" );

?>
Problem: I can't get my items in the email. Any idea's?

Thanks in advance!

Posted: Thu Jan 29, 2004 3:50 pm
by Straterra
If you are going to put those variables in there like that, use HEREDOC.

Posted: Thu Jan 29, 2004 4:16 pm
by Robbie1974
Straterra wrote:If you are going to put those variables in there like that, use HEREDOC.
I've tried this with the HEREDOC code, but it did not work.

My only problem is how to insert the following code in my mail section:

Code: Select all

<script LANGUAGE="JavaScript">
        showItems();
</script>

Posted: Thu Jan 29, 2004 4:21 pm
by Draco_03
http://ca2.php.net/types.string read this about heredoc.. it's not hard to use.. and it "should" work.. it'll be easyer to read and to code

Re: Mail problem

Posted: Wed Sep 07, 2005 1:03 pm
by J_Iceman05
Robbie1974 wrote:

Code: Select all

.........
.........


mail("$receipt,$email", "Online bestelling", "$message", "From:$receipt" );

?>
Problem: I can't get my items in the email. Any idea's?

Thanks in advance!
if i am reading what you were trying to do correctly... you used the mail() function incorrectly
syntax is as follows

Code: Select all

mail($to_whom, $subject, $body, $additional_header);
you have the subject and body switched

or you can visit the following link and get a much more detailed description of the function
http://us2.php.net/manual/en/function.mail.php

I realize this is 1 1/2 years late... but just incase you for some reason havn't solved it yet (for who knows why) or for any future visitors who have the same problem

Posted: Wed Sep 07, 2005 7:32 pm
by John Cartwright
Please don't dig up old threads :?

Posted: Thu Sep 08, 2005 11:56 am
by J_Iceman05
as far as digging up old threads go, i was looking for possible previous situations to help me with my problem. this was there, so im sure i'm not the only one who looks for previous problems of others. and i say if you can simply expand on an existing thread for that situation, it leaves room for new threads for different situations instead of the person needing to post thier own simply because the thread they did find didn't contain the needed info on THIER similar problem.

Posted: Thu Sep 08, 2005 12:06 pm
by John Cartwright
If you are having a similar problem create a new thread, and if there is useful information in another thread feel free [to]feyd share it.

Posted: Thu Sep 08, 2005 1:11 pm
by patrikG
locked.