> From: Dean Ouellette [mailto:[EMAIL PROTECTED]] > Sent: Monday, July 22, 2002 9:43 AM > Subject: [PHP] Newbie getting close, form submission > I am a complete newbie, search the web for examples right now and use > them. > > The host has php 3.0. ^^^^^^^^^^^^^^^^^^^^^ That's really old, you really ought to be using 4.2.x
> > Having problems with for submission > Right now, no error messages, but does not actually send the email. > Ideas? > > <? > $MailToAddress = "[EMAIL PROTECTED]"; > $MailSubject = "Get Involved 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; // could put $Footer inside double quotes, vars >expand then > } > > mail( "$MailToAddress", "$MailSubject", "$Message", "From: // no need to quote these > $MailFromAddress"); > > ?> There's no need to be doing all of the array manipulation. Just use the variables in the array. Also turn off magic_quotes_gpc in a .htaccess file so that you don't have to strip slashes. <?php If ('GET' == $HTTP_SERVER_VARS['REQUEST_METHOD']) { $MailToAddress = '[EMAIL PROTECTED]'; $MailSubject = 'Get Involved List'; ?> <form here> <?php exit; } ?> <? If ('POST' == $HTTP_SERVER_VARS['REQUEST_METHOD']) { if (isset($HTTP_POST_VARS['email'])) { $MailFromAddress = $HTTP_POST_VARS['email']; // I'm assuming the vars were posted from a form } else { $MailFromAddress = '[EMAIL PROTECTED]'; // vars don't expand in single quotes, but we don't have any here. } $Message = $HTTP_POST_VARS['Message']; // should single quote associative array indexes if (isset($HTTP_POST_VARS['Header'])) { $Message = "{$HTTP_POST_VARS['Header']}\n\n$Message"; // need to wrap arrays in double quotes in {} to parse } if (isset($HTTP_POST_VARS['Footer'])) { $Message .= "\n\n{$HTTP_POST_VARS['Footer']}"; } mail($MailToAddress,$MailSubject,$Message,$MailFromAddress); // don't have to quote vars on parms } ?> -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php