Page 1 of 1

PHP send form help

Posted: Tue Mar 31, 2009 12:47 pm
by rafi717
i stiched together this simple form post to send the information from my quote form to the email.

It has a validation word "bingo"

it works fine in Firefox, but in IE instead of going to the "thankyou" page it always send the user to the error page (as if the word wasnt entered...)

Here is the script

Code: Select all

 
if($word_ok!==false)
{
    if($word_ok=="yes")
    {
        echo die();
    } else {
        echo '<META HTTP-EQUIV=Refresh CONTENT="0; URL=http://www.....'.$url.'">';
    }
}
// Subject of email sent to you.
$subject = 'Results from Contact form';
 
// Your email address. This is where the form information will be sent.
$emailadd = 'a@a.com';
 
// Where to redirect after form is processed.
$url = 'http://...';
 
// 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(strtolower($_POST['word']) != 'bingo') 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.'">';
?>
 
Thanks for all the help!

Re: PHP send form help

Posted: Sat Jun 06, 2009 10:17 am
by akuji36
Have a look at php switch. I like it better than if else

http://www.tizag.com/phpT/switch.php