Page 1 of 1

having email generator problem

Posted: Sun Nov 23, 2008 2:46 am
by mellowman
ok i got my form and php kinda to work but when it click submit this comes up

Code: Select all

Warning: Cannot modify header information - headers already sent by (output started at /home/content/p/l/i/plinskidesign/html/web4designzsite/web4designfoler/contacts/feedback.php:9) in /home/content/p/l/i/plinskidesign/html/web4designzsite/web4designfoler/contacts/feedback.php on line 89
heres my feedback.php

Code: Select all

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
 
<body>
<?php
 
// ------------- CONFIGURABLE SECTION ------------------------
 
// $mailto - set to the email address you want the form
// sent to, eg
//$mailto               = "youremailaddress@example.com" ;
 
$mailto = '-------------------' ;
 
// $subject - set to the Subject line of the email, eg
//$subject      = "Feedback Form" ;
 
$subject = "Contact Form" ;
 
// the pages to be displayed, eg
//$formurl              = "http://www.example.com/feedback.html" ;
//$errorurl             = "http://www.example.com/error.html" ;
//$thankyouurl  = "http://www.example.com/thankyou.html" ;
 
$formurl = "http://web4designz.com/contacts.html" ;
$errorurl = "http://web4designz.com/error.html" ;
$thankyouurl = "http://web4designz.com/thankyou.html" ;
 
$email_is_required = 1;
$name_is_required = 1;
$uself = 0;
$use_envsender = 0;
$use_utf8 = 1;
 
// -------------------- END OF CONFIGURABLE SECTION ---------------
 
$headersep = (!isset( $uself ) || ($uself == 0)) ? "\r\n" : "\n" ;
$content_type = (!isset( $use_utf8 ) || ($use_utf8 == 0)) ? 'Content-Type: text/plain; charset="iso-8859-1"' : 'Content-Type: text/plain; charset="utf-8"' ;
if (!isset( $use_envsender )) { $use_envsender = 0 ; }
$envsender = "-f$mailto" ;
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
 
if (!isset($_POST['email'])) {
        header( "Location: $formurl" );
        exit ;
}
if (($email_is_required && (empty($email) || !ereg("@", $email))) || ($name_is_required && empty($name))) {
        header( "Location: $errorurl" );
        exit ;
}
if ( ereg( "[\r\n]", $name ) || ereg( "[\r\n]", $email ) ) {
        header( "Location: $errorurl" );
        exit ;
}
if (empty($email)) {
        $email = $mailto ;
}
 
if (get_magic_quotes_gpc()) {
        $comments = stripslashes( $comments );
}
 
$messageproper =
        "This message was sent from:\n" .
        "$http_referrer\n" .
        "------------------------------------------------------------\n" .
        "Name of sender: $name\n" .
        "Email of sender: $email\n" .
        "------------------------- COMMENTS -------------------------\n\n" .
        $comments .
        "\n\n------------------------------------------------------------\n" ;
 
$headers =
        "From: \"$name\" <$email>" . $headersep . "Reply-To: \"$name\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.12.0" .
        $headersep . 'MIME-Version: 1.0' . $headersep . $content_type ;
 
if ($use_envsender) {
        mail($mailto, $subject, $messageproper, $headers, $envsender );
}
else {
        mail($mailto, $subject, $messageproper, $headers );
}
header( "Location: $thankyouurl" );
exit ;
 
?>
</body>
</html>

Re: having email generator problem

Posted: Sun Nov 23, 2008 3:17 am
by josh
rtfm or google it

Re: having email generator problem

Posted: Sun Nov 23, 2008 11:07 am
by mellowman
how am i suppose to google a huge ass line of error....and im new to the hole php language so i dont realy have experince.... :cry:

Re: having email generator problem

Posted: Sun Nov 23, 2008 11:42 am
by josh

Re: having email generator problem

Posted: Mon Nov 24, 2008 3:37 am
by EPX
try this:

at the very very top of your page before any html put:
<?php
ob_start();
?>

after you have done your code to send your emails put:

<?php
ob_flush();
?>

this bit of code buffers all the information in your page, meaning it won't submit the headers untill the ob_flush() has been declared. this should do the job.

Re: having email generator problem

Posted: Mon Nov 24, 2008 7:16 am
by josh
EPX wrote:at the very very top of your page before any html put:
<?php
ob_start();
?>
This is just a band-aid. If you just want it to work and not learn why you got the error, this is fine.

Re: having email generator problem

Posted: Thu Nov 27, 2008 12:41 am
by mellowman
already fixed it :]

Re: having email generator problem

Posted: Fri Nov 28, 2008 9:12 am
by josh
yayy