problen with header

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
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

problen with header

Post 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]
Last edited by nutstretch on Sun Jul 18, 2004 10:07 am, edited 1 time in total.
User avatar
pelegk2
Forum Regular
Posts: 633
Joined: Thu Nov 27, 2003 5:02 am
Location: Israel - the best place to live in after heaven
Contact:

Post by pelegk2 »

tell us what is line 21 execlly in your code?
kettle_drum
DevNet Resident
Posts: 1150
Joined: Sun Jul 20, 2003 9:25 pm
Location: West Yorkshire, England

Post by kettle_drum »

You have already sent some data to the user (probably a white space on the line after <?php).
redmonkey
Forum Regular
Posts: 836
Joined: Thu Dec 18, 2003 3:58 pm

Post 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...
nutstretch
Forum Contributor
Posts: 104
Joined: Sun Jan 11, 2004 11:46 am
Location: Leicester

Post by nutstretch »

line 21 is:

header( "Location: $thanks" );
User avatar
JAM
DevNet Resident
Posts: 2101
Joined: Fri Aug 08, 2003 6:53 pm
Location: Sweden
Contact:

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