Page 1 of 1
mailing $_POST variables
Posted: Mon Jan 27, 2003 1:05 pm
by kendall
Hi,
Im having a bit of a problem mailing $_POST variables using the mail() function
i have the following code required from a file which mails $_POST variables after they are validated and entered into a database
while(list($key,$value)=each($_POST)){
$message .= $key.":".$value."\n";
}
$subject = "POST information from USER: ".$USER;
mail('
kendall@apex-solutions.com',$subject,$message);
I get the email but no message
just running tru the code description i am trying to concatenate the key value pairs in to message variable before i send it off.
Am i using this part correctly as i can't seem to pin point a problem
Kendall
Posted: Mon Jan 27, 2003 1:29 pm
by puckeye
Hi Kendall,
Have you tried to place a counter in the while loop? It might tell you how many times it went through. If it returns 0 then you might want to take a look at you $_POST variable in case it's emptied earlier before the while loop...
Is the result verified in the same file without reloading?
Posted: Tue Jan 28, 2003 2:30 am
by twigletmac
Have you tried putting:
Code: Select all
echo '<pre>';
print_r($_POST);
echo '</pre>';
in the script that receives the POST variables from the form to make sure that they're getting passed ok?
Mac
mailing $_POST variables
Posted: Tue Jan 28, 2003 7:01 am
by kendall
Hey,
ok heres what i did.
instead of the while...list loop i did a foreach and it was able to produce the 'elements' in the post array.
so if it was able to do a foreach without error. why is it not displaying a 'key : value '. does it have to do with an incorrect order of the array or something?
im a bit confused now as to what to look for as a possible error
Kendall
mailing $_POST variables
Posted: Tue Jan 28, 2003 7:17 am
by kendall
Hey guys,
i have a question but first heres the scenario
on posting a form
the script calls a function from a required file to validate
i then do a while list loop to check the $POSTs to replace empty values with 'NULL'
it is then placed in a database
and then after i do the while list loop to generate a "key : value" string to be sent in as a message mail()
Now the part where i replace the empty values wit 'NULL' does this have anything to do with it??
my theory is maybe when i while list i have a if empty replace the value in the post array wit null. i think therefore i am redefinint he variable and is not a POSTed variable anymore.
but then my question is isnt it a global variable and even if it is the same $_POST so while isnt it recognising it at the end.
now as a test i inserted the code in question and placed it at the begining of the script and it worked. so why isnt it working at the end??
any takers?
?Kendall
mailing $_POST variables
Posted: Tue Jan 28, 2003 12:11 pm
by kendall
Hey guys,
am this is weird but
it seems to work when i just list the values using the foreach loop
but doesnt list anything when i use a while(list....each($_POST))
what gives here
?