while loop question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • JackM

    while loop question

    I am processing a form submission using POST method. Since some of the
    fields are going to be blank and I want to eliminate getting those in
    the email sent to me, I have put this code together that seems to work
    okay and not throw any errors:

    <?php
    error_reporting (E_ALL);
    while(list($key , $val) = each($_POST)){
    if(is_array($va l)){

    foreach($val as $element)
    $mesg .= "$key: $element\n";
    }
    if($val == "") {
    unset($key,$val );
    }
    else
    $mesg .= "$key: $val\n\n";
    }

    $to = 'foo@foo.com';
    $subject = 'Info Submission';
    $header = "From: $_POST[email]\r\n";

    mail( $to,
    $subject,
    $mesg,
    $header
    );
    ?>

    But what puzzles me is that when I echo the results of $mesg to the
    page, it's fine. But when it sends to me in an email, I get an extra
    period (.) about five or six lines down on every submission and I can't
    find out why.

    I know it's not exactly an earth-shaking problem but I'm curious as to
    what I may have done wrong so I can correct it and make sure I don't
    repeat it in the future.

    Thanks for any help.
Working...