Page 1 of 1

Redirect submission form, need help.

Posted: Wed Oct 12, 2005 6:30 pm
by WithHisStripes
Heya,
I have a submission for that I need to have redirected to a thank you page but my code isn't working. Can anyone tell me how I can do it? Thanks

-Spence

Posted: Wed Oct 12, 2005 6:59 pm
by Nathaniel
Post your code.

Posted: Wed Oct 12, 2005 7:04 pm
by WithHisStripes

Code: Select all

$msg="Email to send notification to: " . $_POST['email'] . "\n";

$headers="From: " . $_POST['email']. "\n";

mail('spencer@firstcause.org', "Notify me when the site is complete!", $msg, $headers);

Posted: Wed Oct 12, 2005 7:11 pm
by Zoxive
Whats not working? What error do you get, wheres your redirection?
Could you show use the rest of the code for that page? and others linked to it.

That code apears to be correct, besides a space, between $_POST['email'] and . , but that shouldn't matter.

-NSF

Posted: Wed Oct 12, 2005 7:22 pm
by Nathaniel
after the mail() call, add

Code: Select all

header('Location: http://www.firstcause.org/thankyou.php');
exit;
The exit; call is very important. :)

Posted: Wed Oct 12, 2005 7:46 pm
by WithHisStripes
That didn't seem to work. I got this message:


Warning: Cannot modify header information - headers already sent by (output started at /usr/home/firstcau/public_html/maintenance/process.php:9) in /usr/home/firstcau/public_html/maintenance/process.php on line 17

Here is my new code with your snippet in there:

Code: Select all

$msg="Email to send notification to: " . $_POST['email'] . "\n";

$headers="From: " . $_POST['email']. "\n";

mail('spencer@firstcause.org', "Notify me when the site is complete!", $msg, $headers);

header('Location: http://www.firstcause.org/maintenance/s ... ssful.htm'); 
exit;

Posted: Wed Oct 12, 2005 8:20 pm
by feyd

Posted: Wed Oct 12, 2005 8:41 pm
by WithHisStripes
Thanks, but that didn't help. Any other ideas?

Posted: Wed Oct 12, 2005 8:49 pm
by Nathaniel
You have whitespace or echo'ed content somewhere in your script before that header call. Kill it, because it's the only source of that error message.

Posted: Thu Oct 13, 2005 5:57 am
by WithHisStripes
Okay, I guess I just don't understand what echo'd is. Because here is my exact code:

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>process</title>
</head>

<body>
<?php
header('Location: http://www.google.com'); 
exit;

$msg="Email to send notification to: " . $_POST['email'] . "\n";

$headers="From: " . $_POST['email']. "\n";

mail('spencer@firstcause.org', "Notify me when the site is complete!", $msg, $headers);
?>
</body>
</html>
So what am I overlooking?

Posted: Thu Oct 13, 2005 7:43 am
by feyd

Code: Select all

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>process</title>
</head>

<body>
is all "echo," text output, in your case.

Posted: Thu Oct 13, 2005 8:56 am
by chrys
also, the header() function call needs to go after the mail() call.

Posted: Thu Oct 13, 2005 7:23 pm
by WithHisStripes
Thanks SO much guys, I really appreciate the help. You were right, I had to take out anything that wasn't within the

Code: Select all

<?php ?>
tags. You guys are lifesavers!