Redirect submission form, need 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
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Redirect submission form, need help.

Post 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
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post by Nathaniel »

Post your code.
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Post 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);
User avatar
Zoxive
Forum Regular
Posts: 974
Joined: Fri Apr 01, 2005 4:37 pm
Location: Bay City, Michigan

Post 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
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post 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. :)
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Post 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;
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Post by WithHisStripes »

Thanks, but that didn't help. Any other ideas?
User avatar
Nathaniel
Forum Contributor
Posts: 396
Joined: Wed Aug 31, 2005 5:58 pm
Location: Arkansas, USA

Post 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.
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Post 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?
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post 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.
User avatar
chrys
Forum Contributor
Posts: 118
Joined: Tue Oct 04, 2005 9:41 am
Location: West Roxbury, MA (Boston)

Post by chrys »

also, the header() function call needs to go after the mail() call.
WithHisStripes
Forum Contributor
Posts: 131
Joined: Tue Sep 13, 2005 7:48 pm

Post 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!
Post Reply