HAE guys am in a big problem my boss wants me to create a comment page on my website and ave problems with declaring variables. you can view my website from www.meliaproject.org and go to contact page and see the error am getting please someone sort me out with this codes. coz i want to secure my job

The error is "Warning: Cannot modify header information - headers already sent by (output started at /home/meliapro/public_html/feedback.php:9) in /home/meliapro/public_html/feedback.php on line 144"

You are obviously doing something on line 144 of feedback.php which involves setting headers, but you have already sent something to the browser in line 9. It may be a blank line.

You will need to post the code in feedback.php to get an exact answer.

this is feedback.html

<td align="left" valign="top"><p>for more information please send your comments through</p>
          <form action="feedback.php" method="post">
<table border="0" cellpadding="8" cellspacing="8">
<tr><td width="92"><label for="tswname">Name</label>:</td><td width="652"><input type="text" name="fullname" id="tswname" size="25"></td></tr>
<tr><td><label for="tswemail">Email address</label>:</td><td><input type="text" id="tswemail" name="email" size="25"></td></tr>
<tr>
<td colspan="2">
<label for="tswcomments">Comments</label><br>
<textarea rows="10" cols="60" name="comments" id="tswcomments"></textarea></td>
</tr>
<tr>
<td align="center" colspan="2">
<input type="submit" value="Send Feedback"><br>
</tr>
</table>
</form>
 </p></td>
      </tr>
    </table>

feed back.php

</head>

<body>
<?php



$mailto = 'info@meliaproject.org' ;
$subject = "Feedback Form" ;
$formurl = "http://www.meliaproject.org/feedback.html" ;
$errorurl = "http://www.meliaproject.org/error.html" ;
$thankyouurl = "http://www.meliaproject.org/thankyou.html" ;

$email_is_required = 1;
$name_is_required = 1;
$comments_is_required = 1;
$uself = 0;
$use_envsender = 0;
$use_sendmailfrom = 0;
$smtp_server_win = '' ;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$my_recaptcha_private_key = '' ;



define( 'MAX_LINE_LENGTH', 998 );
$headersep = (!isset( $uself ) || !$uself) ? "\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 ; }
if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {
    ini_set( 'sendmail_from', $mailto );
}
if (isset( $smtp_server_win ) && strlen($smtp_server_win)) {
    ini_set( 'SMTP', $smtp_server_win );
}
$envsender = "-f$mailto" ;
$fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_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) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {
    header( "Location: $errorurl" );
    exit ;
}
if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {
    header( "Location: $errorurl" );
    exit ;
}
if (strlen( $my_recaptcha_private_key )) {
    require_once( 'recaptchalib.php' );
    $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
    if (!$resp->is_valid) {
        header( "Location: $errorurl" );
        exit ;
    }
}
if (empty($email)) {
    $email = $mailto ;
}
$fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;

if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
    $comments = stripslashes( $comments );
}

$messageproper =
    "This message was sent from:\n" .
    "$http_referrer\n" .
    "------------------------------------------------------------\n" .
    "Name of sender: $fullname\n" .
    "Email of sender: $email\n" .
    "------------------------- COMMENTS -------------------------\n\n" .
    wordwrap( $comments, MAX_LINE_LENGTH, "\n", true ) .
    "\n\n------------------------------------------------------------\n" ;

$headers =
    "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.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>

thankyou.html

<title>THANK YOU</title>
</head>

<body>
THANK YOU........... YOUR COMMENT HAS BEEN SUBMITED
</body>
</html>

error.html

<title>meliaproject</title>
</head>

<body>
ERROR......PLEASE FILL IN THE MISSING FIELDS 
</body>
</html>

i will highly apriciate

You have a html code before the <?php code at the beginning of feedback.php, which is sent to the browser before the header is sent further down in the code.

hi, dear...

instead of using the php code in html tags try to use include function for implementing the php code...

hae i tried the ways you suggested to me and they were of help though they show me the text is sent though i find a failure notice on my in box.check on http://www.meliaproject.org .
this is the code as i edited it.
your help will be highly appreciated

<?php
$mailto = 'info@meliaproject.org' ;
$subject = "Feedback Form" ;
$formurl = "http://www.meliaproject.org/feedback.html" ;
$errorurl = "http://www.meliaproject.org/error.html" ;
$thankyouurl = "http://www.meliaproject.org/thankyou.html" ;

$email_is_required = 1;
$name_is_required = 1;
$comments_is_required = 1;
$uself = 0;
$use_envsender = 0;
$use_sendmailfrom = 0;
$smtp_server_win = '' ;
$use_webmaster_email_for_from = 0;
$use_utf8 = 1;
$my_recaptcha_private_key = '' ;



define( 'MAX_LINE_LENGTH', 998 );
$headersep = (!isset( $uself ) || !$uself) ? "\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 ; }
if (isset( $use_sendmailfrom ) && $use_sendmailfrom) {
    ini_set( 'sendmail_from', $mailto );
}
if (isset( $smtp_server_win ) && strlen($smtp_server_win)) {
    ini_set( 'SMTP', $smtp_server_win );
}
$envsender = "-f$mailto" ;
$fullname = (isset($_POST['fullname']))? $_POST['fullname'] : $_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) || !preg_match('/@/', $email))) || ($name_is_required && empty($fullname)) || ($comments_is_required && empty($comments))) {
    header( "Location: $errorurl" );
    exit ;
}
if ( preg_match( "/[\r\n]/", $fullname ) || preg_match( "/[\r\n]/", $email ) ) {
    header( "Location: $errorurl" );
    exit ;
}
if (strlen( $my_recaptcha_private_key )) {
    require_once( 'recaptchalib.php' );
    $resp = recaptcha_check_answer ( $my_recaptcha_private_key, $_SERVER['REMOTE_ADDR'], $_POST['recaptcha_challenge_field'], $_POST['recaptcha_response_field'] );
    if (!$resp->is_valid) {
        header( "Location: $errorurl" );
        exit ;
    }
}
if (empty($email)) {
    $email = $mailto ;
}
$fromemail = (!isset( $use_webmaster_email_for_from ) || ($use_webmaster_email_for_from == 0)) ? $email : $mailto ;

if (function_exists( 'get_magic_quotes_gpc' ) && get_magic_quotes_gpc()) {
    $comments = stripslashes( $comments );
}

$messageproper =
    "This message was sent from:\n" .
    "$http_referrer\n" .
    "------------------------------------------------------------\n" .
    "Name of sender: $fullname\n" .
    "Email of sender: $email\n" .
    "------------------------- COMMENTS -------------------------\n\n" .
    wordwrap( $comments, MAX_LINE_LENGTH, "\n", true ) .
    "\n\n------------------------------------------------------------\n" ;

$headers =
    "From: \"$fullname\" <$fromemail>" . $headersep . "Reply-To: \"$fullname\" <$email>" . $headersep . "X-Mailer: chfeedback.php 2.16.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 ;

?>

is this php code is working correctly?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.