Click to See Complete Forum and Search --> : Pyro's PHP form mailer


chris9902
11-08-2003, 07:24 AM
I need some help with this Form Mailer

<?PHP

#######################################################
# This script is Copyright 2003, Infinity Web Design #
# Distributed by http://www.webdevfaqs.com #
# Written by Ryan Brill - ryan@infinitypages.com #
# All Rights Reserved - Do not remove this notice #
#######################################################

## The lines below need to be edited...

###################### Set up the following variables ######################
#
$to = "you@your.com"; #set address to send form to
$subject = "Results from your Request Info form"; #set the subject line
$headers = "From: Form Mailer"; #set the from address, or any other headers
$forward = 0; # redirect? 1 : yes || 0 : no
$location = "thankyou.htm"; #set page to redirect to, if 1 is above
#
##################### No need to edit below this line ######################

## set up the time ##

$date = date ("l, F jS, Y");
$time = date ("h:i A");

## mail the message ##

$msg = "Below is the result of your feedback form. It was submitted on $date at $time.\n\n";

if ($_SERVER['REQUEST_METHOD'] == "POST") {
foreach ($_POST as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}
else {
foreach ($_GET as $key => $value) {
$msg .= ucfirst ($key) ." : ". $value . "\n";
}
}

mail($to, $subject, $msg, $headers);
if ($forward == 1) {
header ("Location:$location");
}
else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}

?>

when i press submit it shows a plain text page then re-directs people, is there a way to just re-direct people without them seeing the plain page sayingThank you for submitting our form. We will get back to you as soon as possible.

YoN
11-08-2003, 04:03 PM
it should be setting $forward to 1 in the line $forward = 0; # redirect? 1 : yes || 0 : no and don't forget to set properly $location to the page you want to redirect.

chris9902
11-08-2003, 06:20 PM
Originally posted by chris9902
is there a way to just re-direct people without them seeing the plain page.

it re-direct after you have seen the plain page with the message on, i want it to skip that and just re-direct people

YoN
11-08-2003, 07:28 PM
It's weird since the if-else conditional makes it re-direct or display the message but not both. try changing it to if ($forward == 1) {
header ("Location:$location");
} else {
echo "Thank you for submitting our form. We will get back to you as soon as possible.";
}
...although i believe it's the same thing.
If that doesn't work, change that part to just header ("Location:$location");

chris9902
11-09-2003, 04:42 AM
ok thank you.

maybe i was doing something wrong in the first place.

pyro
11-09-2003, 06:14 PM
Originally posted by chris9902
it re-direct after you have seen the plain page with the message on, i want it to skip that and just re-direct people Actually, it couldn't even do that... ;)

Headers (including redirects) do not work after content has been sent to the browser, so it would not display the message and then redirect you. Even if it tried to do that, it would display the message, and then an error. :)

chris9902
11-10-2003, 12:50 AM
i think it is a error on my part then

sorry bout that;)