smordue Posted December 3, 2009 Share Posted December 3, 2009 I am trying to get the email inserted from a flat file for the formhandler but this code is not working right <?php $email = $HTTP_POST_VARS; $mailto = "<? $lines = file('basedata.txt'); $l_count = count($lines); for($x = 0; $x< $l_count; $x++) { } echo "" . $lines[9] . "" ; ?>"; $mailsubj = "Website Contact Form submission"; $mailhead = "From: $email\n"; reset ($HTTP_POST_VARS); $mailbody = "Values submitted from web site contact form:\n"; while (list ($key, $val) = each ($HTTP_POST_VARS)) { $mailbody .= "$key : $val\n"; } if (!eregi("\n",$HTTP_POST_VARS)) { mail($mailto, $mailsubj, $mailbody, $mailhead); } ?> Any ideas? Steve Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/ Share on other sites More sharing options...
minidak03 Posted December 3, 2009 Share Posted December 3, 2009 I'm not 100% sure if I'm understanding this right but try the following. <?php $email = $HTTP_POST_VARS[email]; $lines = file('basedata.txt'); foreach($lines as $line) { $mailto = $line; $mailsubj = "Website Contact Form submission"; $mailhead = "From: $email\n"; $mailbody = "Values submitted from web site contact form:\n"; foreach( $HTTP_POST_VARS as $key => $val ) { $mailbody .= "$key : $val\n"; } if(!eregi("\n",$HTTP_POST_VARS[email])) { mail($mailto, $mailsubj, $mailbody, $mailhead); } } ?> If that doesn't work can you explain a little more what is going on? What are the errors? is the email being sent but the data is displayed incorrectly? Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970867 Share on other sites More sharing options...
premiso Posted December 3, 2009 Share Posted December 3, 2009 If you, or your host updated PHP recently, $HTTP_POST_VARS is depreciated: http://www.php.net/manual/en/reserved.variables.post.php $_POST -- $HTTP_POST_VARS [deprecated] — HTTP POST variables I would change them to be $_POST instead and see if that possibly fixes your problem. As far as the actual problem, you never really told us what was "wrong". You just stated you had a problem. What specifically is going wrong? As mini hinted, we need that information to better help you without it we are just in a sloppy pen trying to catch a crisco greased up pig, pretty tough. Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970869 Share on other sites More sharing options...
smordue Posted December 4, 2009 Author Share Posted December 4, 2009 Thanks for your replies, I have a flat text file with several lines in it. I use the code above throughout my site with no problems. However on this formhandler page, which is for my contact page, I was trying to use the same script to insert the "send to" address. I get this Parse error: syntax error, unexpected '<' in /public_html/websites/base/formhandler.php on line 43 This is the beginning of the line that starts "$mailto = "<?" Is this because I am using a script, within a script? Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970920 Share on other sites More sharing options...
minidak03 Posted December 4, 2009 Share Posted December 4, 2009 Is this because I am using a script, within a script? Basically yes, you cannot do what you did (example below) $mailto = "<? $lines = file('basedata.txt'); $l_count = count($lines); for($x = 0; $x< $l_count; $x++) { } echo "" . $lines[9] . "" ; ?>"; But you can do something like I did in my previous post. Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970955 Share on other sites More sharing options...
smordue Posted December 6, 2009 Author Share Posted December 6, 2009 Where do I enter the line number of basedata.txt? The email address I want to grab is on line 9. Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-972146 Share on other sites More sharing options...
smordue Posted December 7, 2009 Author Share Posted December 7, 2009 Anybody? Quote Link to comment https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-972920 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.