Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

php email problem

Status
Not open for further replies.

jreinard

Technical User
Feb 21, 2001
24
0
0
US
Hello all,
I am writing a php script that sends an email via a web form. I am trying to suppress the information that is null so it will not be included in the email. The email send and recieves fine, but the information is not being included in the email. It is acting as though everything is null. But here is the crazy part. If I am using a Mac(regardless of browser), the form will work fine and the information is supplied in the email.Yet on any PC(regardless of browser) the email returns nothing.
Here is the code. Any help would be greatly appreciated!!

<?


if (!is_array($HTTP_POST_VARS)) //validates array
return;
reset($HTTP_POST_VARS);


while
(list($key, $val) = each($HTTP_POST_VARS)) { //traverses the array
if ($val!=&quot;&quot;){
$GLOBALS[$key] = $val;
$val=stripslashes($val);
echo &quot;<b>$key</b> = $val<br>&quot;;
$Message .= &quot;$key = $val\n&quot;;
}}



if ($Header) {
$Message = $Header.&quot;\n\n&quot;.$Message;
}

if ($Footer) {
$Message .= &quot;\n\n&quot;.$Footer;
}


mail( &quot;$MailToAddress&quot;, &quot;$MailSubject&quot;, &quot;$Message&quot;, &quot;From: $MailFromAddress&quot;);
?>
 
Does your echo statement output anything?

Also,

$HTTP_POST_VARS (or $_POST) is always an array, and always exists, even if the script has had nothing posted to it. Testing whether it is an array will always return true.

It is not necessary to set the key/value pair from $HTTP_POST_VARS as key/value pairs in $GLOBALS. $GLOBALS contains everything (including itself, which is why using print_r() on $GLOBALS is not a good idea), so the data is already there. ______________________________________________________________________
TANSTAAFL!
 
My echo statement in fact outputs the information that is desired when using a Mac. (ie. input name of the form, and the data associated with it) Yet when using a PC nothing shows at all. It seems as though the echo statement is not working.
I am using

if (!is_array($HTTP_POST_VARS)) //validates array
return;
reset($HTTP_POST_VARS);

to reset the form once the user has come back to this page, via a refer statement, at the end of the html page.

<br><br>
<b>Thank You!</b>
<br><br>
<a href=&quot;<? echo &quot;$HTTP_REFERER&quot;; ?>&quot;>Return To The Literature Request Form</a><br><br>
<a href=&quot;/&quot;>Home Page</a><br><br>
</body>
</html>

Any ideas as to why the echo statement might not be working properly?
 
You do realize that the line which returns will never run, right? Since &quot;is_array($HTTP_POST_VARS)&quot; will always return true, PHP will never perform the return. $HTTP_POST_VARS always exists, even if you have not POSTed anything. If you don't POST, then it exists as an empty array, but an array nonetheless.

Also, I don't understand what you mean by &quot;reset the form&quot;. All reset() does is move the internal pointer of an array back to the first element of the array.

I doubt the problem is with echo. PHP will use the same echo (or print) command regardless of the browser used, and will output the data in the same way. It's probably a rendering problem of some kind -- for example, the output is inside a <table> tag but not inside a <td> tag. One browser renders it the way you expect, the other in a weird place or not at all, even if both are IE -- there is no guaranty Mi¢ro$oft used the same rendering engine source code on the Mac as on Win32. ______________________________________________________________________
TANSTAAFL!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top