I have a PHP script for my contact form. It works properly when the form is filled out, but it also sends out blank emails and I am not sure if they are empty forms or forms that have been filled out, but will not show.
The blank emails come in as "Results from form:".
Any help is great help, thank you! I am sorry if this has been reposted a hundred times, but I looked through this question and each gave a different answer and I do not know PHP. If you know of the correct answer please redirect me to that thread. Thank you!
Here is my script:
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'New BrandoArts.com Client';
// Your email address. This is where the form information will be sent.
$emailadd = '
[email protected]';
// Where to redirect after form is processed.
$url = 'http://www.brandoarts.com/thankyou.html';
// Makes all fields required. If set to '1' no field can not be empty. If set to '0' any or all fields can be empty.
$req = '1';
// --------------------------Do not edit below this line--------------------------
$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.'">';
?>
[attachment deleted by admin]