SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    shopping cart problems

    Hi,

    I have been working on a shopping cart application. Got it working pretty well. I recently found two problems that I can't figure out.

    When a user places an order, a confirmation email is sent out. I was using my yahoo account to test this and it all worked fine. When I send it to a pop3 which I have configured for outlook, only the first header gets sent and the other headers get sent as part of the mailbody. It is HTML email but the resulting message is full of html tags which is not good. I do normally receive HTML messages on this account so I don't think it's a configuration problem on my end.

    The other problem, totally unrelated to the email problem but both are in the same PHP document, is with unsetting session variables. I found the function unset() in the PHP manual but it doesn't seem to work for me. After the order is confirmed, I unset a bunch of session vars using unset() but they're still there afterwards. Here's the code.
    PHP Code:
    $recipient $email;
    $subject 'Order confirmation from mysite.com';
    $mailbody '';
    $headers 'MIME-Version: 1.0' "\r\n";
    $headers .= 'Content-type: text/html; charset=iso-8859-1' "\r\n";
    $headers .= 'From: mysite.com <orders@mysite.com>' "\r\n";

    dbconnect_null();

    foreach (
    $invoice as $v) {
       if (
    $v == 'items') {
          for (
    $i=0$i<count($item_list); $i++) {
             
    $mailbody .= "\n" $item_list[$i];
             
    $p $items[$i]['pid'];
             
    $sqlquery "SELECT quantity FROM catalog WHERE id = '$p'";
             
    $result mysql_query($sqlquery);
             
    $q mysql_result($result0'quantity') - $items[$i]['quantity'];
             
    $sqlquery "UPDATE catalog SET quantity = '$q' WHERE id = '$p'";
             
    mysql_query($sqlquery);

          }
       } elseif (
    $v == 'choice'$mailbody .= "\n" '<tr><td>Order confirmed</td></tr>';
       else 
    $mailbody .= "\n" $v;
    }
    mysql_close();
    mail($recipient$subject$mailbody$headers);
    unset(
    $_SESSION['shoppingcart']);
    unset(
    $_SESSION['count']);
    unset(
    $_SESSION['item_count']);
    unset(
    $_SESSION['cart_status']); 
    $_SESSION['confirmed'] = 1
    Thanks
    Last edited by rozner; Jul 23, 2003 at 10:47.

  2. #2
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ok, I've fixed the sessions problem by using this:
    PHP Code:
    $_SESSION['shoppingcart'] = NULL;
    // and so on 
    but still having the email problem. Any help is appreciated. Thanks.

  3. #3
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know if this applies, but I found the following note on the php docs for the mail functoin:

    Quote Originally Posted by PHPNotes
    I noticed when sending html mail to ms outlook 2000 outlook will not interpret correctally the headers unless you place a space between the \r\n appending the header line so that it looks like:

    $header = "From: somebody <somebody@somewhere.com>\r \n";

    This seems to work in all other email clients I have tried it on so far (Mozilla, TWIG) without breaking them. Trust M$ to use screwy headers. The behavior I recieved out of outlook was that the first header was recognized as a header and all other headers after that one were placed in the body of the message.

    Jeff
    My name is Steve, and I'm a super-villian.

  4. #4
    SitePoint Wizard rozner's Avatar
    Join Date
    Oct 2002
    Location
    Paris
    Posts
    1,058
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that fixed the problem. Thanks

  5. #5
    La la la la la bronze trophy lieut_data's Avatar
    Join Date
    Jun 2003
    Location
    Waterloo, ON
    Posts
    1,517
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Glad to help!

    Cheers!
    My name is Steve, and I'm a super-villian.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •