Page 1 of 1

Need Help with a form script

Posted: Fri Aug 21, 2009 9:36 pm
by mb716
I need help from someone who knows php. I downloaded a script for a form that sends a confirmation number when the form is sent. It is called Message Confirmed. I keep getting an error message when the form is submitted:

Warning: Invalid argument supplied for foreach() in /home/content/s/t/c/stcocrime09/html/mc120203/msg_conf.php on line 42



The email goes through, and gives a confirmation number, but the message typed in the box doesn't come through the email.

Here is a link to the page with the form: http://www.steubencountycrimestoppers.o ... 3/form.htm


I have contacted the developer but cannot get a response. Can someone take a look at the code and let me know what needs to be done to get this to work? Do I need to do something with databases on the server?

Here is the code in question. line 42 is where it gives me the foreach () error message

<?php

// Message Confirmed - A form to mail system that assigns a confirmation number
// which is posted to the e-mail and given to the user whom has filled out your
// form. This allows for easier reference in correspondence. This can be tied
// into many of our other scripts for use in work-orders, assignments, service-
// oriented business and countless other application.
//
// See license.txt for licensing info on this script.
include "header.php";
print "<P>";
require "config.php";


// get the counter number
$count_file = fopen("$counter_file", "r");
while (!feof($count_file))
{
$number = fread($count_file, 1024);
}
$conf_no = "$pre_conf$number";
fclose($count_file);
// Got the counter number, now move on.

// Open the counter and increase the number by one.
$fileopen = fopen("$counter_file", "w");
flock($fileopen, LOCK_EX);
$new_number = ($number + 1);
fwrite($fileopen, "$new_number");
fclose($fileopen);
// Finnished with the math!


$mailTo = "$send_to_addr";

$mailSubject = "$mail_subject : $conf_no";

$mailBody = "The form values entered by the user are as follows: \n\n";

$mailBody .= "Confirmation No. $conf_no. \n\n";

foreach($HTTP_POST_VARS as $key=>$value)
{

$mailBody .= "$key = $value\n";

}


$mailBody .= "\n\n";

if ($show_ip_address == "on")
{

$mailBody .= "THE IP ADDRESS OF THE FORM USER IS: $REMOTE_ADDR\n\n";

}


$mailBody .= "\nThis message sent via MyKazaam.Com! \n VISIT US AT HTTP://WWW.MYKAZAAM.COM \n";


$fromHeader = "From: $mail_from\n";


if(mail($mailTo, $mailSubject, $mailBody, $fromHeader))
{

print ("<B>Your form has been submitted!</b><br>");
print ("<B>Your Confirmation Number is: $conf_no.</b><br>");
print ("<a href=\"$finnish_page\">Click Here to continue</a><P>");

}

include "footer.php";
?>

Re: Need Help with a form script

Posted: Fri Aug 21, 2009 9:55 pm
by SidewinderX
$HTTP_POST_VARS has been depreciated. Use $_POST instead.

Re: Need Help with a form script

Posted: Sat Aug 22, 2009 7:36 am
by mb716
I tried the $POST and I still get the same error message:

Warning: Invalid argument supplied for foreach() in /home/content/s/t/c/stcocrime09/html/mc120203/msg_conf.php on line 42

Re: Need Help with a form script

Posted: Sat Aug 22, 2009 7:38 am
by mb716
I made a mistake. I put $POST not $_POST. I went back and corrected it and it is working now. Thanks so so much.