Created a form and found simple php script to send results to email doesn't work
I've created a form and put it on my site but right now it's only a pseudo form because it does nothing, when submit is hit. I've found this php script and modified it to send the results to my email. When the form's filled out and submit is hit, the visitor is sent to the actual php page, even though they should go to a refreshed version of my site. This is the name of my site ( www.theapartmentinsiders.com ) where the nonfunctioning form resides and here is the php code that I've modified and uploaded into the scripts folder:
<?php
//--------------------------Set these paramaters--------------------------
// Subject of email sent to you.
$subject = 'You have a message from your site';
// Your email address. This is where the form information will be sent.
$emailadd = 'alan@theapartmentinsiders.com';
// Where to redirect after form is processed.
$url = 'http://www.theapartmentinsiders.com';
// 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 = '0';
// --------------------------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.'">';
?>
If I can get this form to work, I'll be beyond thrilled. By work I mean, e-mail me the results and redirect the site vistor to a designated page.
Thanks in advance.
