RE: [PHP] Newbie getting close, form submission

From: Date: Mon, 22 Jul 2002 14:55:53 +0000
Subject: RE: [PHP] Newbie getting close, form submission
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-108866@lists.php.net to get a copy of this message
I do not control server they will not upgrade. It is a tiny local host, they suck, but the owner of site insists on using them. Getting this Parse error: parse error, expecting STRING' or NUM_STRING' or `'$'' in /www/docs/site/email.php on line 78 This is the section $Message = $HTTP_POST_VARS['Message']; // should single quote associative array indexes if (isset($HTTP_POST_VARS['Header'])) { <<<<This is 78>>>> $Message = "{$HTTP_POST_VARS['Header']}\n\n$Message"; // need to wrap arrays in double quotes in {} to parse } -----Original Message----- From: Matt Schroebel [mailto:MSchroebel@hsus.org] Sent: Monday, July 22, 2002 10:36 AM To: 'Dean Ouellette'; php-general@lists.php.net Subject: RE: [PHP] Newbie getting close, form submission > From: Dean Ouellette [mailto:dean@ouellette.ws] > 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@myaddress.com"; > $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@myaddress.com'; $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 = 'me@mydomain.com'; // 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

« previous php.general (#108866) next »