Please help - Cannot modify header information - headers already sent by

Please Help me to solve below problem :

“Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/842/7119842/public_html/com_bestbrowser/config.php:22) in /storage/ssd1/842/7119842/public_html/com_bestbrowser/post_comment.php on line 27”

I saw this Topic is already in forum but the solution given by teodor is out of my knowledge, I am not so much expert in php.

My code is given below, please help me to solve above problem :

<?php include("config.php"); include("functions.php"); $author = mysqli_real_escape_string($conn, $_POST['name']); $email = mysqli_real_escape_string($conn, $_POST['email']); $comment_body = mysqli_real_escape_string($conn, $_POST['comment_body']); $parent_id = mysqli_real_escape_string($conn, $_POST['parent_id']); $toEmail = "MyEmail@gmail.com"; $mysub = "Comment on Best Web Browser at : www.WatchOutOnNet.com "; $mailHeaders = "From: " . $_POST['name'] . "<". $_POST['email'] .">\r\n"; $q = "INSERT INTO com_bestbrowser (author, email, comment, parent_id) VALUES ('$author', '$email', '$comment_body', $parent_id)"; $r = mysqli_query($conn,$q); if(mysqli_affected_rows($conn)==1) { mail($toEmail, $mysub, $comment_body, $mailHeaders); header("index.php"); // Which is : https://watchoutonnetcom.000webhostapp.com/com_bestbrowser/ } else { echo "Comment cannot be posted. Please try again."; } ?>

Try adding this to your .htaccess :slight_smile:

php_flag output_buffering on 
1 Like

H i ckhawand,

thanks for your helping hands.

I added your given line… it IS just suppressing the errors BUT NOT REDIRECTING TO PAGE AS SUGGESTED IN HEADER ( header(“index.php”); )

Any further advise ? Please help

Try

header('Location: index.php');