Re: newbie form problem
| From: | Justin French | Date: | Sun, 21 Jul 2002 13:52:23 +0000 |
| Subject: | Re: newbie form problem | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-108723@lists.php.net to get a copy of this message | ||
What version of PHP are you running? If it's >= 4.1, then you should be
using the $_POST array for the post vars.
It looks to me that you're just trying to loop through the POSTed vars, and
print them as the message... if so, try something like this:
<?
$MailToAddress = "myemail@here.com";
$MailSubject = "Group volunteer list";
if (!$MailFromAddress) {
$MailFromAddress = "$email";
}
$Header = "";
$Footer = "";
foreach($_POST as $key => $val)
{
$val = stripslashes($val);
$Message .= "$key = $val\n";
}
if ($Header) {
$Message = $Header."\n\n".$Message;
}
if ($Footer) {
$Message .= "\n\n".$Footer;
}
mail($MailToAddress, $MailSubject, $Message, "From: {$MailFromAddress}");
?>
Untested code of course :)
1. I'm not really sure why you were testing if HTTP_POST_VARS *wasn't* an
array (pretty sure it's always an array)
2. I'm not really sure what you were doing with $GLOBALS, but the above
should achieve what you want.
3. In the mail() (and in most of PHP) you don't need to put double quotes
around $vars... only $vars within strings... and it also helps to wrap $vars
within strings inside {curly braces} eg "From: {$MailFromAddress}"
Justin French
on 21/07/02 11:11 PM, Dean Ouellette (dean@ouellette.ws) wrote:
> I have a form and I cannot figure out why this is not working.
> Not getting any error messages, I am just not getting the e-mail to show
> the form was filled out.
>
> Here it is, any help much appreciated, thanks
>
> <?
> $MailToAddress = "myemail@here.com";
> $MailSubject = "Group volunteer list";
> if (!$MailFromAddress) {
> $MailFromAddress = "$email";
> }
> $Header = "";
> $Footer = "";
> ?>
>
>
> <?
> if (!is_array($HTTP_POST_VARS))
> return;
> reset($HTTP_POST_VARS);
> while(list($key, $val) = each($HTTP_POST_VARS)) {
> $GLOBALS[$key] = $val;
> $val=stripslashes($val);
>
> $Message .= "$key = $val\n";
> }
>
> if ($Header) {
> $Message = $Header."\n\n".$Message;
> }
>
> if ($Footer) {
> $Message .= "\n\n".$Footer;
> }
>
> mail( "$MailToAddress", "$MailSubject", "$Message", "From:
> $MailFromAddress");
> ?>
>