0
votes

I have a header page which includes navbar and necessary css's, js's.

I'm trying call the header page from contact page but there was something going wrong.

I take this error on the contact page.

  • Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at C:\xampp\htdocs\test\includes\header.php:84) in C:\xampp\htdocs\test\contact.php on line 3

following the contact page codes.

<?php include_once ("includes/config.php");
include_once ("includes/header.php");
session_start();
require_once'includes/phpmailer/security.php';
?>


<div class="container">
    <div class="contact">

        <?php if(isset($_GET['CaptchaPass'])){?>
        <div >message sent</div>
        <?php } ?>
        <?php if(isset($_GET['CaptchaFail'])){?>
        <div >message failed</div>
        <?php } ?>

        <form action="includes/contact-config.php" method="post">
            <div class="form-group">
                <label for="name">Your Name *</label>
                <input type="text" name="name" autocomplete="off" required="" class="form-control" placeholder="Enter Name"  <?php echo isset ($fields['name'])? 'value="'.e($fields['name']).'"':''?>>
            </div>
            <div class="form-group">
                <label for="email">Your Email address * </label>
                <input type="email" name="email" autocomplete="off" required=""  class="form-control" placeholder="Enter Email"<?php echo isset ($fields['email'])? 'value="'.e($fields['email']).'"':''?>>
            </div>
            <div class="form-group" >
                <label for="message">Your Message *</label>
                <textarea class="form-control" rows="8" id="comment" required=""  name="message"<?php echo isset ($fields['message'])? e($fields['message']):''?>></textarea>
                <br>
                <div class="g-recaptcha" data-sitekey="6LcyfhgUAAAAAKunkwqqxFJSOPUzYbNmppLQbcWc"></div>


                <input type="submit" value="Send" id="ContactButton" class="form-control" class="btn btn-primary">
            </div>
        </form>

    </div>
</div>
</body>

<?php include ("includes/footer.php");?>

header.php folder path--> C:\xampp\htdocs\test\includes\header.php

contact.php folder path --> C:\xampp\htdocs\test\contact.php

1
your config.php or header.php is sending some outputs. move session_start before the includesbansi
Thanks for response bahsi :')user6517184

1 Answers

1
votes

Most likely issue is that the includes/config.php or includes/header.php is outputting something to the browser - probably white space.

If these files have a closing PHP tag ?>, removing them should help solve the issue. Also make sure none of the files are using echo or print or other output functions.