Jump to content


help me plzz


  • Please log in to reply
4 replies to this topic

#1 _*Magnetronkip_*

_*Magnetronkip_*
  • Guests

Posted 11 August 2004 - 02:44 PM

hi there iam new to php but iam learning fast
i made a form mail but when i send it
i will get this error

Warning: Cannot modify header information - headers already sent by (output started at /home/flash-heaven/public_html/test/sendmail.php:9) in /home/flash-heaven/public_html/test/sendmail.php on line 38

i use 2 php files
sendmail.php
<? 
$subj = $_POST['subj']; // Get the subject 
$name = $_POST['name']; // Get the name 
$email = $_POST['email']; // Get the e-mail 
$site = $_POST['url']; // Get the url 
$comments = $_POST['comments']; // Get the message 
$ip = $_SERVER[REMOTE_ADDR]; // Get the IP 
$host = GetHostByAddr($ip); // Get the host 
// Set some variables for the date 
$day = date("l"); 
$date = date("j of F"); 
$year = date("Y"); 
$time = date("g:i A"); $to = "[email protected]"; // Your e-mail 
$subject = "¡Form Mailer! $subj"; // The subject 


// Set some header info 
$headers = "To: Your Name \r\n"; 
$headers .= "From: $name <$email>\r\n"; // Don't change 
$headers .= "Reply-To: $email\r\n"; // Don't change 

// The next line is the actual body of the e-mail,
$body = "Name: $name\r\nE-Mail: $email\r\nWebsite: $site\r\n
Comments:\r\n$comments\r\n\n---Info---\r\n
IP: $ip@$host\r\nDate: $day the $date, $year\nTime: $time"; 

mail($to,$subject,$body,$headers); // Let's send the e-mail! 


header("Location: sendmail.php"); 
// After the mail has been sent, redirect the visitor to a new page
and mail.php
<p>&nbsp;</p>
<form action="sendmail.php" method="post">
<span style="font-size: 8pt;">Your E-Mail:</span><br />
<input type="text" name="email" value="" >
<br /><br />
<span style="font-size: 8pt;">Your Name:</span><br />
<input type="text" name="name" value="" >
<br /><br />
<span style="font-size: 8pt;">Your Website:</span><br />
<input type="text" name="url" value="" >
<br /><br />
<span style="font-size: 8pt;">Subject [Please fill in, or your E-Mail may be ignored]:</span><br />
<input type="text" name="subj" value="" >
<br /><br />
<span style="font-size: 8pt;">Comments:</span><br />
<textarea name="comments" rows="5" ></textarea>
<br/ ><br />
<input type="submit" value="Send E-Mail">
</form>

but i can find it help me plzz

#2 _*Dabu_*

_*Dabu_*
  • Guests

Posted 11 August 2004 - 03:10 PM

add

ob_start();

to the top o fall your php pages.

#3 _*Magnetronkip_*

_*Magnetronkip_*
  • Guests

Posted 11 August 2004 - 03:46 PM

doesnt seems to work

#4 _*mYth_*

_*mYth_*
  • Guests

Posted 11 August 2004 - 06:55 PM

headers are kinda gay, well some what.

This should be the last thing called to the page, this line would normally follow a exit() function which stops the script.

The absolutly critcial thing to remember about the header() function is that it must be called before anything is sent to the web browser. This includes HTML or even blank spaces.. No echo()s or print() statements, blank lines outside of PHP tags and even include files that do the same.

I dont like this:
// Set some header info
$headers = "To: Your Name \r\n";
$headers .= "From: $name <$email>\r\n"; // Don't change
$headers .= "Reply-To: $email\r\n"; // Don't change


header("Location: sendmail.php");

Why do you want to send it back where you are? Try using a full absolute path ie http://www.url.com/page.php And whats on line 38?

#5 _*Magnetronkip_*

_*Magnetronkip_*
  • Guests

Posted 12 August 2004 - 03:37 AM

when the mail is send i want to go back to the homepage but how?
adn this is on line 38
37:header("Location: sendmail.php"); 
38:// After the mail has been sent, redirect the visitor to a new page  

[edit]oke problem is done how do i send i back to the home page?[edit]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users