Mail problem

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Locked
Robbie1974
Forum Newbie
Posts: 8
Joined: Thu Jan 29, 2004 3:27 pm
Location: Blankenberge - Belgium

Mail problem

Post 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!
Straterra
Forum Regular
Posts: 527
Joined: Mon Nov 24, 2003 8:46 am
Location: Indianapolis, Indiana
Contact:

Post by Straterra »

If you are going to put those variables in there like that, use HEREDOC.
Robbie1974
Forum Newbie
Posts: 8
Joined: Thu Jan 29, 2004 3:27 pm
Location: Blankenberge - Belgium

Post 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>
Draco_03
Forum Regular
Posts: 577
Joined: Fri Aug 15, 2003 12:25 pm
Location: Montreal, Canada

Post 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
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

Re: Mail problem

Post 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
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

Please don't dig up old threads :?
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

Post 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.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post 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.
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

locked.
Locked