Forums

PHP

This topic is locked

php redirect with header()

Posted 27 May 2006 15:31:04
1
has voted
27 May 2006 15:31:04 don rose posted:
I have a simple email form that I want to send and then have the browser redirect to a thank you page. The form is mailed but the redirect does not work, I get a new blank form. Thanks in advance! Here's the code:

<?php
if($_POST['action'] == "send"
{
$message = "";
$message .= "User has filled in the Mail form at " . date("H:i" . " on " . date("m/d/Y" . "\n\n";
$message .= "Name: " . $_POST['frm_name'] . "\n";
$message .= "Organization: " . $_POST['frm_org'] . "\n";
$message .= "Email: " . $_POST['frm_email'] . "\n";
$message .= "Response: " . $_POST['frm_response'] . "\n";
$message .= "Question: " . $_POST['frm_quest'] . "\n";
$to = " ";
$subject = "Question from Website";
$headers = "From: \r \n";
$headers .= "X-Priority: 1 \r \n";
$headers .= "X-MSMail-Priority: High";
mail($to,$subject,$message,$headers);
header("Location: thankyou.php";
}
?>

Replies

Replied 29 May 2006 11:45:40
29 May 2006 11:45:40 Patrick Woldberg replied:
Don't you get a warning? You probably have send something to the screen before the redirect, make sure that the code you posted is on top of your document and there isn't anything before it, also no spaces.

--------------------------------------------------
Patrick Woldberg
Web Developer at Dynamic Zones
Administrator at DMXzone.com, FLzone.net, FWzone.net and DNzone.com
--------------------------------------------------
Replied 29 May 2006 21:24:07
29 May 2006 21:24:07 don rose replied:
I took the essentials of the code (php + forms) and put it into a temp doc to testing. With this, I get the following warning:
Warning: Cannot modify header information - headers already sent by (output started at /home/cygnalgr/public_html/temp.php:8) in /home/cygnalgr/public_html/temp.php on line 24

What does this mean? How far to the top of the doc does the php code need to be?

You can get to the temp file at: www.cygnalgroup.com/temp.php

Replied 30 May 2006 11:36:31
30 May 2006 11:36:31 Roddy Dairion replied:
Like patrick said you probably need to check whether you have a blank line and spaces before the header.

Reply to this topic