Hello there...
i watch the Php Academy tutorial of contact forum the thing happening is when i create it in single file it work.
BUT

When I include it in a file it echo errors

Cannot modify header information - headers already sent by (output started at /home/iconspor/public_html/contact.php:11) in /home/iconspor/public_html/contact.php on line 87

Codes are below.

<?php //include ("connection.php");?>
<!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>iCON SPORTS</title>
<link href="css/style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0" class="wrapper">
  <tr>
    <td width="100%" height="100%" align="center" valign="top"><table width="993" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td align="center" valign="middle" class="heading_txt" height="10px"></td>
      </tr>
      <tr>
        <td width="993" align="center" valign="middle" class="heading_txt"><?php //include ("template/header.php");?></td>
      </tr>
      <tr>
        <td width="996" align="center" valign="top"><table width="996" border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td width="996" align="left" valign="top"><?php //include ("template/nav_bar.php");?></td>
          </tr>
          <tr>
            <td width="996" align="left" valign="top"><table width="993" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td width="993" align="center" valign="top"><table width="993" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td width="160" align="center" valign="top" > </td>
                    <td width="733" height="350" align="center" valign="top" style="padding-top:20px; padding-bottom:50px;">
                    </u><span class="heading">CONTACT US</span></strong><br />
                      <br />
                      <br />
                      <span class="txt_area"> </span></p>
                      <table width="400" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="300" align="center" valign="middle"  
                          style="padding-left:50px; font-family:Arial;font-size:13px;color:#FFF;"><table width="350" border="0" cellspacing="0" cellpadding="0">
<tr >
<td align="left" valign="top" style="border-bottom:solid 1px #FFF; padding-top:10px; padding-bottom:10px;"><span class="contact_heading">Head Office.</span><br />
Me<span class="contact">lbourne Victo</span>ria 1 Brett drive carrum downs 3201<br />
Email :  <span class="contact"><a href="mailto:faisal@icon-sports.com.au" class="contact">faisal@icon-sports.com.au</a></span><a href="mailto:faisal@icon-sports.com.au" target="_blank" class="contact"><br />
</a>Ph:   0421741271  <br /></td>
                            </tr>
                            <tr>
                              <td align="left" valign="top" style="border-bottom:solid 1px #FFF; padding-top:10px; padding-bottom:10px;"><strong class="contact_heading">Western Australia Contact</strong><br />
Contact Person:   Warren Snyman  <br />
Ph:   0405733730  </td>
                            </tr>
                            <tr>
                              <td align="left" valign="top" style="border-bottom:solid 1px #FFF; padding-top:10px; padding-bottom:10px;"><strong class="contact_heading">Footy Department Contact</strong><br />
Contact Person :   Glenn Harvey  <br />
Ph:   0417368682  </td>
                            </tr>
                            <tr>
                              <td align="left" valign="top" style="border-bottom:solid 1px #FFF; padding-top:10px; padding-bottom:10px;"><strong class="contact_heading">Indoor Cricket  Contact</strong><br />
Contact Person:   Craig Slocombe  <br />
Ph:   0426508409  </td>
                            </tr>
                            <tr>
                              <td align="left" valign="top" style="border-bottom:solid 1px #FFF; padding-top:10px; padding-bottom:10px;"><?php 
if(empty($_POST) === false){
    $errors = array();

    $name       =$_POST['name'];
    $email      =$_POST['email'];
    $message    =$_POST['message'];

    if(empty($name)=== true || empty($email) === true || empty($message) === true ){
        $errors[] = 'Name, Email and Message are Requires';
    }else {
            if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){
            $errors[] = 'Please Enter a validate email address!';
            }
            if(ctype_alpha($name)=== false){
            $errors[] = 'Name Only Contain Letters!';

            }
        }

    if(empty($errors) === true){
        // Sendin Email
        mail("mir.jde@gmail.com", "Mail From Web","$message","From:".$email);
        // Redirect Page
        header("location:contact.php?sent");
        exit();

        }

}
?>

    <?php 

         if(isset($_GET['sent']) === true){
        echo'<p> Thanks For Contacting Us!</p>';
        }
        else{


    if(empty($errors)=== false){

    echo '<ul>';
    foreach($errors as $errors){
    echo '<li>',$errors,'</li>';

    }

    echo '</ul>';
    }
    ?>  
        <form action="" method="post">

        <p>
        <label for="name" >Name:</label><br>
        <input type="text" name="name" id="name" <?php if(isset ($_POST['name']) === true) {echo 'value="', strip_tags ($_POST['name']),'"'; }?> />
        </p>
        <p>
        <label for="email" >Email:</label><br>
        <input type="text" name="email" id="email" <?php if(isset ($_POST['email']) === true) {echo 'value="', strip_tags ($_POST['email']),'"'; }?> />
        </p>
        <p>
        <label for="message" >Message:</label><br>
        <textarea name="message" id="message"> <?php if(isset ($_POST['message']) === true) {echo strip_tags ($_POST['message']);}?>

Use ob_start() at the top of your file from where the file starts

commented: it. works..! +0

can you share me your connection.php source code??

Try
move this section of code from the end of line 62-92

<?php if(empty($_POST) === false){
  $errors = array();
  $name=$_POST['name'];
  $email=$_POST['email'];
  $message=$_POST['message'];
  if(empty($name)=== true || empty($email) === true || empty($message) === true ){  $errors[] ='Name, Email and Message are Required';}
  else { if(filter_var($email, FILTER_VALIDATE_EMAIL) === false){ $errors[] = 'Please Enter a valid email address!';}
  if(ctype_alpha($name)=== false){    $errors[] = 'Name Only Contain Letters!';}
     }
if(empty($errors) === true){
     // Sendin Email
      mail("mir.jde@gmail.com", "Mail From Web","$message","From:".$email);
       // Redirect Page
       header("location:contact.php?sent");
         exit(); }
         }
         ?>

to line 2
tht will get error checking and the header redirect before anyhtml output

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.