Hello everybody,
I'm having a bit of problems with a simple form to email. I have a .html page that has a form. I want the contents of the form to be sent to my email everytime the form is submitted. I would really appreciated if you guys can help me out. Thanks.
Here are my problems:
1) After pressing submit on my form, it takes me to a another page that says:
Invalid argument supplied foreach() on line 9 and the next second sends me to the thanks page which I created after a user sends the form.
2) When I look at my email I receive a email, but when I open it, none of the contents of the form are available. In other words, it comes empty.
Here's the script:
<?php
$subject = 'Contact me';
$emailadd = 'agpmpsae@gmail.com';
$url = '../thanks.html';
$req = '1';
$text = "Results from form:\n\n";
$space = ' ';
$line = ' ';
foreach ($_POST as $key => $value)
{
if ($req == '1')
{
if ($value == '')
{echo "$key is empty";die;}
}
$j = strlen($key);
if ($j >= 20)
{echo "Name of form element $key cannot be longer than 20 characters";die;}
$j = 20 - $j;
for ($i = 1; $i <= $j; $i++)
{$space .= ' ';}
$value = str_replace('\n', "$line", $value);
$conc = "{$key}:$space{$value}$line";
$text .= $conc;
$space = ' ';
}
mail($emailadd, $subject, $text, 'From: '.$emailadd.'');
echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL='.$url.'">';
?>
Just in case, I did the phpinfo() and found out this:
PHP version 4.0.6
system: Linux
Server API: Apache
Virtual Directory support: disabled
Configuarition File (php.ini) Path: /etc/httpd/php.ini
ZEND_DEBUG: disabled
Thanks 😃 ,
agpm