Jump to content

formhandler problem


smordue

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970867
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970869
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970920
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/183908-formhandler-problem/#findComment-970955
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.