Page 1 of 1

problen with header

Posted: Sun Jul 18, 2004 6:20 am
by nutstretch
feyd | You've been here long enough to know to use

Code: Select all

tags when posting code. [b]FINAL WARNING[/b] Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]


I am trying to do a page which sends me an email when a user has clicked a certain button. and then post them on to the index page when they have.
The following code is my test sample:

Code: Select all

<?php

$name = "132";
$subject = "User clicked through to cosyfeet";
$email = "website@mywesite.co.uk";
$radd = "angie@mywebsite.co.uk";
$thanks = "http://www.mywebsite.co.uk/index.html";
$mail = ("
Some one has clicked through to cosyfeet
---------------------------------------------------------------------\n
Name: $name \n

---------------------------------------------------------------------\n
Brought to you by Angie

");

mail( $radd, $subject,
        $mail, "From: $email" );
header( "Location: $thanks" );
?>
It is not redirection and instead i get this message:

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home/virtual/site280/fst/var/www/html/dbshoes/testing.php:2) in /home/virtual/site280/fst/var/www/html/dbshoes/testing.php on line 21
Anyone know what I am doing wrong?


feyd | You've been here long enough to know to use

Code: Select all

tags when posting code. [b]FINAL WARNING[/b] Read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url][/color]

Posted: Sun Jul 18, 2004 6:58 am
by pelegk2
tell us what is line 21 execlly in your code?

Posted: Sun Jul 18, 2004 7:22 am
by kettle_drum
You have already sent some data to the user (probably a white space on the line after <?php).

Posted: Sun Jul 18, 2004 8:04 am
by redmonkey
kettle_drum wrote:You have already sent some data to the user (probably a white space on the line after <?php).
White spcae within the php tags does not matter. It is only data that is sent to the buffer that counts. The only data sent out to the buffer from within php tags is via echo, print, heredoc etc...

Posted: Sun Jul 18, 2004 10:06 am
by nutstretch
line 21 is:

header( "Location: $thanks" );

Posted: Sun Jul 18, 2004 10:25 am
by JAM
You should verify that all variables are indeed filled with something.

Code: Select all

// similiar to this
// mail( $radd, $subject, $mail, "From: $email" );
echo( $radd, $subject, $mail, "From: $email" );
// header( "Location: $thanks" );
You could try adding this

Code: Select all

error_reporting(E_ALL)
in line 2 to make sure that the script isn't producing any errors that you are missing because your error-settings are to low in the php.ini file.


[Edit: Removed some text due to the fact that others completely misunderstood the point of the post. -- JAM]