RE: [PHP] Newbie getting close, form submission
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
RE: [PHP] Newbie getting close, form submission
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:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 10:36 AM To: 'Dean Ouellette'; [EMAIL PROTECTED] Subject: RE: [PHP] Newbie getting close, form submission 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 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie getting close, form submission
From: Dean Ouellette [mailto:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 10:56 AM Subject: RE: [PHP] Newbie getting close, form submission $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; Oops, PHP 3.0 may need: $Message = $HTTP_POST_VARS['Header'] . \n\n$Message; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] Newbie getting close, form submission
Last line Same error for this message Parse error: parse error, expecting `STRING' or `NUM_STRING' or `'$'' in /www/docs/www.electjoemarine.com/email.php on line 82 Was $Message .= \n\n{$HTTP_POST_VARS['Footer']}; Tried this, but same message $Message .= \n\n$HTTP_POST_VARS['Footer']; -Original Message- From: Matt Schroebel [mailto:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 11:21 AM To: 'Dean Ouellette'; Matt Schroebel; [EMAIL PROTECTED] Subject: RE: [PHP] Newbie getting close, form submission From: Dean Ouellette [mailto:[EMAIL PROTECTED]] Sent: Monday, July 22, 2002 10:56 AM Subject: RE: [PHP] Newbie getting close, form submission $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; Oops, PHP 3.0 may need: $Message = $HTTP_POST_VARS['Header'] . \n\n$Message; } -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie getting close, form submission
On Monday 22 July 2002 23:44, Dean Ouellette wrote: Tried this, but same message $Message .= \n\n$HTTP_POST_VARS['Footer']; $Message .= \n\n$HTTP_POST_VARS[Footer]; -- Jason Wong - Gremlins Associates - www.gremlins.com.hk Open Source Software Systems Integrators * Web Design Hosting * Internet Intranet Applications Development * /* You can extend EXTRAVERSION infinitely, but after the first 10 or so characters, it starts to get silly. - Russell King on linux-kernel */ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Newbie getting close, form submission
I pointed this out to you in my original post: you mail() call should be: mail($MailToAddress, $MailSubject, $Message, From: $MailFromAddress); not: mail($MailToAddress, $MailSubject, $Message, From: $MailFromAddress); In other words, I don't think you should wrap plain $vars in double quotes... it may be the cause of the problem, or it may just slow down PHP a little when not needed. For debugging, instead of sending the mail(), just do this: echo To: {$MailToAddress}BR /\n; echo Subject: {$MailSubject}BR /\n; echo Message: {$Message}BR /\n; echo From: {$MailFromAddress}BR /\n; In otherwords, you should be looking to see if each $var you're sending to the mail() function IS WHAT YOU EXPECT, once you're sure they're correct, THEN you can pipe them back into a mail() call, and test. Possibly mail() is not working on the server at all. A great way to test that would be to create a SEPARATE SCRIPT which just has this: ? $to = '[EMAIL PROTECTED]'; $sub = 'really simple test'; $msg = 'testing, testing\n\ntestingtesting'; $header = 'From: [EMAIL PROTECTED]'; mail($to, $sub, $msg, $header); ? The reason for creating a separate script is to ensure that you're only testing the mail() function, not anything else. You could also try turning your error reporting on to a higher level, which may indicate the bug. Justin on 22/07/02 11:42 PM, Dean Ouellette ([EMAIL PROTECTED]) wrote: I am a complete newbie, search the web for examples right now and use them. The host has php 3.0 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; } mail( $MailToAddress, $MailSubject, $Message, From: $MailFromAddress); ? -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php