PHP send form help

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rafi717
Forum Newbie
Posts: 1
Joined: Tue Mar 31, 2009 12:42 pm

PHP send form help

Post 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!
Last edited by Benjamin on Sat Jun 06, 2009 1:38 pm, edited 1 time in total.
Reason: Added [code=php] tags.
User avatar
akuji36
Forum Contributor
Posts: 190
Joined: Tue Oct 14, 2008 9:53 am
Location: Hartford, Connecticut

Re: PHP send form help

Post by akuji36 »

Have a look at php switch. I like it better than if else

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