Hi again,

Thank you, Chris, for your help.  We modified the script as per your suggestions and 
modified a few other things, so that finally, the script does what it is supposed to 
do. 

However, there is another problem now, that happens in the e-mail itself.  An 
exclamation mark appears in the body message.  This only happens in the e-mail that 
contains the Parts information and the exclamation mark seems to always appear in the 
same spot -- 15 lines down and 25 characters to the right.  If there is no text in 
that area, however, we do not see the exclamation mark.  It only appears when there is 
text there.

We did tests in Explorer by having the body print directly in the browser, and the 
exclamation mark does not appear there.  It seems to only happen when the e-mail is 
actually sent.  We've checked in Outlook, Outlook Express and in a Web Mail program, 
and the exclamation appears in all of these.

Here is the script again, below.  I apologize if it isn't very clear!

Thanks again for your help. :-)

Julie

<?php

//Build email Body based on customer request

IF (trim($_POST['custemail'])!='') {
    IF ($_POST['request_type']=="Service_Advice") {
    $body = "Thank you for your request for information. Because it is difficult to 
answer your question via email, the best advice we can offer you is to call your auto 
technician for more information.<BR><BR>Or, for the best service on your Volvo, you 
may want to bring it in for a proper diagnosis to a Volvo specialist. If you are close 
to one of our Swedish Engineering locations, call us for an appointment.<BR><BR>You 
can find our Service Department phone numbers and locations on the following page: <A 
href='http://swedishengineering.com/service.html'>http://swedishengineering.com/service.html</A><BR>(If
 your email client does not allow you to click on the link above, just copy and paste 
it into your browser)<BR><BR>";
    $body .= $_POST['comments'];
    $body .= "<BR><BR>Thank you,<BR><BR>Swedish Engineering Staff";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: [EMAIL PROTECTED]";
    $headers .= "To: ".$_POST['custemail']."\r\n";

    mail($_POST['custemail'], "Your Service Advice Request", $body, $headers);

    header("Location:index.html");
    }

    ELSE IF ($_POST['request_type']=="Parts_Advice") {
    $body = "Thank you for your request for information. Because it is difficult to 
answer your question via email, the best advice we can offer you is to call us for 
more information. We will do our best to help you find the right parts for your 
Volvo.<BR><BR>Please call 1-800-928-6586.<BR><BR>";
    $body .= $_POST['comments'];
    $body .="<BR><BR>Thank you,<BR><BR>Swedish Engineering Staff";
    $headers .= "MIME-Version: 1.0\r\n";
    $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
    $headers .= "From: [EMAIL PROTECTED]";
    $headers .= "To: ".$_POST['custemail']."\r\n";

    mail($_POST['custemail'], "Your Parts Advice Request", $body, $headers);

    header("Location:index.html");
    }

    ELSE IF ($_POST['request_type']=="Parts") {
    IF ((trim($_POST['part1'])=='') && (trim($_POST['part2'])=='') && 
(trim($_POST['part3'])=='') && (trim($_POST['part4'])=='') && 
(trim($_POST['part5'])=='') && (trim($_POST['part6'])=='')) {
    print ("Please go back and include part information.");
    exit;
    }
    ELSE {
    $body = "Thank you for your parts request. The information you requested is listed 
below:<BR>&nbsp;<BR>";
    $body .= "<TABLE>";
    $body .= "<TR><TH>Part #</TH><TH>Part 
Name</TH><TH>Price</TH><TH>Shipping</TH><TH>Availability</TH></TR>";
        IF (trim($_POST['part1'])!=''){
        $body .= 
"<TR><TD>".$_POST['part1']."</TD><TD>".$_POST['partname1']."</TD><TD>".$_POST['price1']."</TD><TD>".$_POST['sprice1']."</TD><TD>".$_POST['avail1']."</TD></TR>";
        }
        IF (trim($_POST['part2'])!=''){
        $body .= 
"<TR><TD>".$_POST['part2']."</TD><TD>".$_POST['partname2']."</TD><TD>".$_POST['price2']."</TD><TD>".$_POST['sprice2']."</TD><TD>".$_POST['avail2']."</TD></TR>";
        }
        IF (trim($_POST['part3'])!=''){
        $body .= 
"<TR><TD>".$_POST['part3']."</TD><TD>".$_POST['partname3']."</TD><TD>".$_POST['price3']."</TD><TD>".$_POST['sprice3']."</TD><TD>".$_POST['avail3']."</TD></TR>";
        }
        IF (trim($_POST['part4'])!=''){
        $body .= 
"<TR><TD>".$_POST['part4']."</TD><TD>".$_POST['partname4']."</TD><TD>".$_POST['price4']."</TD><TD>".$_POST['sprice4']."</TD><TD>".$_POST['avail4']."</TD></TR>";
        }
        IF (trim($_POST['part5'])!=''){
        $body .= 
"<TR><TD>".$_POST['part5']."</TD><TD>".$_POST['partname5']."</TD><TD>".$_POST['price5']."</TD><TD>".$_POST['sprice5']."</TD><TD>".$_POST['avail5']."</TD></TR>";
        }
        IF (trim($_POST['part6'])!=''){
        $body .= 
"<TR><TD>".$_POST['part6']."</TD><TD>".$_POST['partname6']."</TD><TD>".$_POST['price6']."</TD><TD>".$_POST['sprice6']."</TD><TD>".$_POST['avail6']."</TD></TR>";
        $body .= "</TABLE>";
        $body .= "<BR>Please call our service center if you need to reserve them for 
pick up, or to place an order to have them shipped.<BR>";
        $body .= "Our Service Departments are located on the following 
page:<BR>&nbsp;<BR>";
        $body .= "<a 
href='http://swedishengineering.com/service.html'>http://swedishengineering.com/service.html</a><BR>&nbsp;<BR>";
        $body .= "(If your email client does not allow you to click on the link above, 
just copy and paste it into your browser)<BR><BR>";
        $body .= $_POST['comments'];
        $body .= "<BR><BR>Thank you,<BR><BR>Swedish Engineering Staff";
        $headers .= "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=iso-8859-1\r\n";
        $headers .= "From: [EMAIL PROTECTED]";
        $headers .= "To: ".$_POST['custemail']."\r\n";

        mail($_POST['custemail'], "Your Parts Request", $body, $headers);

        header("Location:index.html");
        }
    }
}
ELSE {
print ("Please go back and enter the customer's request type.");
exit;
}
} 
ELSE {
print ("Please go back and enter the customer's email address.");
exit;
}
?>



----- Original Message ----- 
From: "Chris Hayes" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, March 11, 2003 7:22 AM
Subject: Re: [PHP] Script that writes e-mail (well, is supposed to)


> I think your server is ok.
> 
> 
> Your if-else structure was a bit hard to oversee this way. I had to indent 
> your code to see your logic. But maybe the tabs got lost in the email.
> 
> 
> I think readability would improve if you replaced
> 
> ---------------------------------
> IF (isset($_POST['custemail']))
> {//the entire script
> }
> ELSE
> {print "warning message";}
> ---------------------------------
> 
> with
> 
> ---------------------------------
> IF (!isset($_POST['custemail']))
> { print "warning message";
>    exit;
> }
> 
> //rest of the script
> ---------------------------------
> 
> Then, you said:
> >when the client's e-mail address is omitted, a message should appear, 
> >stating "Please go back and enter the customer's e-mail address!", but 
> >instead, it states "Please go back and enter the customer's request type!" 
> >which is a message that should appear when the type is omitted.
> 
> This is about this test:
>          IF (isset($_POST['custemail']))
> Now, probably with your browser, when this field is left empty, 
> $_POST['custemail'] does exist, but is empty.
> So you would need to test for that too:
>          IF (!isset($_POST['custemail']) OR (trim($_POST['custemail'])!='' 
> )  )
> (trim removes spaces)
> 
> BTW it would be a good idea to also make a javascript test for empty fields.
> 
> 
> >Also, when no parts are indicated, a message should appear, to the effect 
> >of "Please go back and enter a part" but instead, the program goes ahead 
> >and sends an empty e-mail to the customer.
> 
> That's about this test:
>   IF ((!isset($_POST['part1'])) && (!isset($_POST['part2'])) && 
> (!isset($_POST['part3'])) && (!isset($_POST['part4'])) && 
> (!isset($_POST['part5'])) && (!isset($_POST['part6'])))
> 
> And here i think it is basically the same problem as described above.
> I would keep it more basic here and replace every !isset($_POST['part1'])
> by
>          (trim($_POST['part1'])!='')
> because apparently it is always set.
> 
> 
> >There are several other errors, basically, none of the commands work properly.
> check the  script for more places where you assume that isset is valid only 
> when somehting is entered in a field
> 
> 
> >We have been banging our heads on our desks for a really long time
> don't do that! in case an IF does not do what you expect it to do, do some 
> very basic tests in a separate script. and check the manual and see the 
> examples.
> 
> 
> >We are beginning to think that the server is possessed
> Of course that IS an option, too. In that case I recommend to go to 
> alt.exorcists.servers ;-P
> 
> 
> 
> -- 
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 

Reply via email to