2016-04-22 62 views
0

警告:無法修改標題信息 - 已在C:\ wamp64 \ www \ FSE \ template \ navigation.php:15中輸出的標題(已輸出) \ wamp64 \ WWW \ FSE \ ADMIN \ reg1.php上線71這個問題,我getting.it很好2天背面的警告效果很好的其他電腦。無法修改標題信息 - 已發送標題(輸出已啓動

下面給的是reg1.php

的代碼下面navigation.php的
<?php 
#start session 
session_start(); 

#database connection 
include('../config/connection.php'); 
include('../config/setup.php'); 

if (!isset($_SESSION['user_name'])) { 
    header('location:login.php'); 
} 


?> 

<html> 
<head> 

    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title><?php echo 'Registration | '.$site_title; ?></title> 

    <?php include('../config/css.php'); ?> 
    <?php include('../config/js.php'); ?>   
</head> 

<body> 
    <?php include('../template/navigation.php'); ?> 
    <h2> <center><strong>General Information </strong></center></h2> 


    <div id="wrap"> 
     <div class="container"> 

      <?php 

      if (isset($_POST['submitted'])==1) { 

       $name = mysqli_real_escape_string($dbc, $_POST['name']); 
       $fname = mysqli_real_escape_string($dbc, $_POST['fathername']); 
       $postadd = mysqli_real_escape_string($dbc, $_POST['postadd']); 
       $personaladd= mysqli_real_escape_string($dbc, $_POST['personaladd']); 
       $sex = mysqli_real_escape_string($dbc, $_POST['sex']); 
       $clients = mysqli_real_escape_string($dbc, $_POST['clients']); 
       $state = mysqli_real_escape_string($dbc, $_POST['state']); 
       $city = mysqli_real_escape_string($dbc, $_POST['city']); 
       $pincode = mysqli_real_escape_string($dbc, $_POST['pincode']); 
       $email = mysqli_real_escape_string($dbc, $_POST['email']); 
       $date = mysqli_real_escape_string($dbc, $_POST['date']); 
       $mobile = mysqli_real_escape_string($dbc, $_POST['mobile']); 


       $q = "INSERT INTO registration (name, fname, postadd, personaladd, sex, clients, state, city, pincode, email, dob, mobile) VALUES ('$name', '$fname', '$postadd', '$personaladd', '$sex', '$clients', '$state', '$city', '$pincode', '$email', '$date', '$mobile')" ; 
       $r = mysqli_query($dbc, $q); 

       if($_POST['clients']=="farmer") 
        { 
         $b = "insert into message values((SELECT reg_id FROM registration ORDER BY reg_id DESC LIMIT 1),(select mobile from registration where reg_id ORDER BY reg_id DESC LIMIT 1),(select Company from seed_testing where State=(select State from registration ORDER BY reg_id DESC LIMIT 1)));"; 
         $c = mysqli_query($dbc, $b); 
        } 


         if ($r) { 

          $value_to_page = array(
         "farmer" => 'farm.php', 
         "investor" => 'interest.php', 

         ); 
        if(isset($_POST['submitted'])){ 

        // process other fields like $_POST['some-other'] 
         if(isset($_POST['clients']) && isset($value_to_page[$_POST['clients']])){ 
       **#line71 error**   header('Location: '.$value_to_page[$_POST['clients']]); 
          return; 
         } 
        } 

         } else { 
         echo 'please enter some data or error :'.mysqli_error($dbc); 
         echo '<p>'.$q.'</p>'; 
         } 
      } 

      ?> 




      <div class="col-md-6 col-md-offset-3"> 


       <form action="reg1.php" method="post" > 

        <div class="form-group"> 
         <label for="name">Name</label> 
         <input type="text" class="form-control" id="name" name="name" placeholder="First name and Surname" required> 
        </div> 


        <div class="form-group"> 
         <label for="fathername">Father Name</label> 
         <input type="text" class="form-control" id="fathername" name="fathername" placeholder="fathername"> 
        </div> 

        <div class="form-group"> 
         <label for="postadd">Postal Address</label> 
         <textarea type="text" class="form-control" id="postadd" name="postadd" placeholder="postal Address"></textarea> 
        </div> 


        <div class="form-group"> 
         <label for="personaladd">Personal Address</label> 
         <textarea class="form-control" id="personaladd" rows="5" name="personaladd" placeholder="personal address"></textarea> 
        </div> 

        <div class="form-group"> 
         <label class="radio-inline"> 
          <input type="radio" name="sex" id="male" value="Male"> Male 
         </label> 
         <label class="radio-inline"> 
          <input type="radio" name="sex" id="female" value="Female"> Female 
         </label> 
        </div> 

        <?php 
        ?> 


        <div class="form-group"> 
         <label class="radio-inline"> 
          <input type="radio" name="clients" id="farmer" value="farmer"> farmer 
         </label> 
         <label class="radio-inline"> 
          <input type="radio" name="clients" id="investor" value="investor"> investor 
         </label> 
        </div> 

        <div class="form group"> 
         <label>state</label> 
         <select class="form-control" name="state"> 
          <option selected="" ></option> 
          <option value="Andra Pradesh">Andra Pradesh</option> 
          <option value="Arunachal Pradesh">Arunachal Pradesh</option> 
          <option value="Assam">Assam</option> 
          <option value="Bihar">Bihar</option> 
          <option value="Chhattisgarh">Chhattisgarh</option> 
          <option value="Delhi">Delhi</option> 
          <option value="Goa">Goa</option> 
          <option value="Gujarat">Gujarat</option> 
          <option value="Haryana">Haryana</option> 
          <option value="Himachal Pradesh">Himachal Pradesh</option> 
          <option value="Jammu and Kashmir">Jammu and Kashmir</option> 
          <option value="Jharkhand">Jharkhand</option> 
          <option value="Karnataka">Karnataka</option> 
          <option value="Kerala">Kerala</option> 
          <option value="Madya Pradesh">Madya Pradesh</option> 
          <option value="maharashtra">Maharashtra</option> 
          <option value="Manipur">Manipur</option> 
          <option value="Meghalaya">Meghalaya</option> 
          <option value="Mizoram">Mizoram</option> 
          <option value="Nagaland">Nagaland</option> 
          <option value="Orissa">Orissa</option> 
          <option value="Punjab">Punjab</option> 
          <option value="Rajasthan">Rajasthan</option> 
          <option value="Sikkim">Sikkim</option> 
          <option value="Tamil Nadu">Tamil Nadu</option> 
          <option value="Tripura">Tripura</option> 
          <option value="Uttaranchal">Uttaranchal</option> 
          <option value="Uttar Pradesh">Uttar Pradesh</option> 
          <option value="West Bengal">West Bengal</option> 

         </select> 
        </div> 

        <div class="form-group"> 
         <label for="name">City</label> 
         <input type="text" class="form-control" id="city" name="city" placeholder="Enter your city"> 
        </div> 


        <div class="form-group"> 
         <label for="pincode">Pin Code</label> 
         <input type="number" class="form-control" id="pincode" name="pincode" placeholder="pincode"> 
        </div> 

        <div class="form-group"> 
         <label for="email">Email id</label> 
         <input type="email" class="form-control" id="email" name="email" placeholder="Email Id"> 
        </div> 

        <div class="form-group"> 
         <label for="dob">Date of Birth</label> 
         <input type="date" class="form-control" id="date" name="date" > 
        </div> 

        <div class="form-group"> 
         <label for="mobile">Mobile no.</label> 
         <input type="number" class="form-control" id="mobile" name="mobile" placeholder="mobile number" > 
        </div> 



        <button type="submit" class="btn btn-primary btn-lg btn-block">Save</button> 
        <input type="hidden" onclick = "jump()" name="submitted" value="1"> 

       </form> 
      </div> 
     </div> 
    </div> 

</body> 
</html> 

線15

<nav class="navbar navbar-inverse" role="navigation"> 
    <div class="container"> 
     <ul class="nav navbar-nav"> 
      <li><a href="#">Home</a></li> 
      <li><a href="#">Contact us</a></li> 
      <li><a href="reg1.php?">registration</a></li> 
      <li><a href="stock.php?">farm stock</a></li> 
     </ul> 

     <div class="pull-right"> 
      <ul class="nav navbar-nav"> 
       <li class="dropdown"> 
      **line 15 error** <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"><?php echo$_SESSION['user_name'];?><span class="caret"></span></a> 
        <ul class="dropdown-menu"> 
         <li><a href="logout.php">Logout</a></li> 


        </ul> 
       </li> 
      </ul> 
     </div> 
    </div> 
</nav> 
+0

,請複製粘貼你完整的代碼,不打破它。只是在你認爲錯誤將要發生的地方發表評論 –

+0

@anand ohk。我已編輯並嘗試解釋它。 幾天前它工作正常。我不知道現在發生了什麼 – Prathameshb7

回答

0

您不能更改標題(即重定向)如果你已經任何東西已經到達頁面。例如,您不能回顯<p>hello</p>,然後執行header('Location....,因爲您已經提供了一些內容。

變化reg1.php此,它應該工作:

<?php 
#start session 
session_start(); 

#database connection 
include('../config/connection.php'); 
include('../config/setup.php'); 

if (!isset($_SESSION['user_name'])) { 
    header('location:login.php'); 
} 

if (isset($_POST['submitted'])==1) { 
    $name = mysqli_real_escape_string($dbc, $_POST['name']); 
    $fname = mysqli_real_escape_string($dbc, $_POST['fathername']); 
    $postadd = mysqli_real_escape_string($dbc, $_POST['postadd']); 
    $personaladd= mysqli_real_escape_string($dbc, $_POST['personaladd']); 
    $sex = mysqli_real_escape_string($dbc, $_POST['sex']); 
    $clients = mysqli_real_escape_string($dbc, $_POST['clients']); 
    $state = mysqli_real_escape_string($dbc, $_POST['state']); 
    $city = mysqli_real_escape_string($dbc, $_POST['city']); 
    $pincode = mysqli_real_escape_string($dbc, $_POST['pincode']); 
    $email = mysqli_real_escape_string($dbc, $_POST['email']); 
    $date = mysqli_real_escape_string($dbc, $_POST['date']); 
    $mobile = mysqli_real_escape_string($dbc, $_POST['mobile']); 


    $q = "INSERT INTO registration (name, fname, postadd, personaladd, sex, clients, state, city, pincode, email, dob, mobile) VALUES ('$name', '$fname', '$postadd', '$personaladd', '$sex', '$clients', '$state', '$city', '$pincode', '$email', '$date', '$mobile')" ; 
    $r = mysqli_query($dbc, $q); 

    if($_POST['clients']=="farmer"){ 
     $b = "insert into message values((SELECT reg_id FROM registration ORDER BY reg_id DESC LIMIT 1),(select mobile from registration where reg_id ORDER BY reg_id DESC LIMIT 1),(select Company from seed_testing where State=(select State from registration ORDER BY reg_id DESC LIMIT 1)));"; 
     $c = mysqli_query($dbc, $b); 
    } 


    if ($r){ 
     $value_to_page = array(
     "farmer" => 'farm.php', 
     "investor" => 'interest.php', 
     ); 

     if(isset($_POST['submitted'])){ 
      // process other fields like $_POST['some-other'] 
      if(isset($_POST['clients']) && isset($value_to_page[$_POST['clients']])){ 
       header('Location: '.$value_to_page[$_POST['clients']]); 
       return; 
      } 
     } 
    } 
    else{ 
     echo 'please enter some data or error :'.mysqli_error($dbc); 
     echo '<p>'.$q.'</p>'; 
    } 
} 
?> 

<html> 
<head> 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
    <title><?php echo 'Registration | '.$site_title; ?></title> 

    <?php include('../config/css.php'); ?> 
    <?php include('../config/js.php'); ?>   
</head> 

<body> 
    <?php include('../template/navigation.php'); ?> 
    <h2><center><strong>General Information </strong></center></h2> 

    <div id="wrap"> 
     <div class="container"> 
      <div class="col-md-6 col-md-offset-3"> 
       <form action="reg1.php" method="post" > 
        <div class="form-group"> 
         <label for="name">Name</label> 
         <input type="text" class="form-control" id="name" name="name" placeholder="First name and Surname" required> 
        </div> 

        <div class="form-group"> 
         <label for="fathername">Father Name</label> 
         <input type="text" class="form-control" id="fathername" name="fathername" placeholder="fathername"> 
        </div> 

        <div class="form-group"> 
         <label for="postadd">Postal Address</label> 
         <textarea type="text" class="form-control" id="postadd" name="postadd" placeholder="postal Address"></textarea> 
        </div> 

        <div class="form-group"> 
         <label for="personaladd">Personal Address</label> 
         <textarea class="form-control" id="personaladd" rows="5" name="personaladd" placeholder="personal address"></textarea> 
        </div> 

        <div class="form-group"> 
         <label class="radio-inline"> 
          <input type="radio" name="sex" id="male" value="Male"> Male 
         </label> 
         <label class="radio-inline"> 
          <input type="radio" name="sex" id="female" value="Female"> Female 
         </label> 
        </div> 

        <div class="form-group"> 
         <label class="radio-inline"> 
          <input type="radio" name="clients" id="farmer" value="farmer"> farmer 
         </label> 
         <label class="radio-inline"> 
          <input type="radio" name="clients" id="investor" value="investor"> investor 
         </label> 
        </div> 

        <div class="form group"> 
         <label>state</label> 
         <select class="form-control" name="state"> 
          <option selected="" ></option> 
          <option value="Andra Pradesh">Andra Pradesh</option> 
          <option value="Arunachal Pradesh">Arunachal Pradesh</option> 
          <option value="Assam">Assam</option> 
          <option value="Bihar">Bihar</option> 
          <option value="Chhattisgarh">Chhattisgarh</option> 
          <option value="Delhi">Delhi</option> 
          <option value="Goa">Goa</option> 
          <option value="Gujarat">Gujarat</option> 
          <option value="Haryana">Haryana</option> 
          <option value="Himachal Pradesh">Himachal Pradesh</option> 
          <option value="Jammu and Kashmir">Jammu and Kashmir</option> 
          <option value="Jharkhand">Jharkhand</option> 
          <option value="Karnataka">Karnataka</option> 
          <option value="Kerala">Kerala</option> 
          <option value="Madya Pradesh">Madya Pradesh</option> 
          <option value="maharashtra">Maharashtra</option> 
          <option value="Manipur">Manipur</option> 
          <option value="Meghalaya">Meghalaya</option> 
          <option value="Mizoram">Mizoram</option> 
          <option value="Nagaland">Nagaland</option> 
          <option value="Orissa">Orissa</option> 
          <option value="Punjab">Punjab</option> 
          <option value="Rajasthan">Rajasthan</option> 
          <option value="Sikkim">Sikkim</option> 
          <option value="Tamil Nadu">Tamil Nadu</option> 
          <option value="Tripura">Tripura</option> 
          <option value="Uttaranchal">Uttaranchal</option> 
          <option value="Uttar Pradesh">Uttar Pradesh</option> 
          <option value="West Bengal">West Bengal</option> 

         </select> 
        </div> 

        <div class="form-group"> 
         <label for="name">City</label> 
         <input type="text" class="form-control" id="city" name="city" placeholder="Enter your city"> 
        </div> 

        <div class="form-group"> 
         <label for="pincode">Pin Code</label> 
         <input type="number" class="form-control" id="pincode" name="pincode" placeholder="pincode"> 
        </div> 

        <div class="form-group"> 
         <label for="email">Email id</label> 
         <input type="email" class="form-control" id="email" name="email" placeholder="Email Id"> 
        </div> 

        <div class="form-group"> 
         <label for="dob">Date of Birth</label> 
         <input type="date" class="form-control" id="date" name="date" > 
        </div> 

        <div class="form-group"> 
         <label for="mobile">Mobile no.</label> 
         <input type="number" class="form-control" id="mobile" name="mobile" placeholder="mobile number" > 
        </div> 

        <button type="submit" class="btn btn-primary btn-lg btn-block">Save</button> 
        <input type="hidden" onclick = "jump()" name="submitted" value="1"> 
       </form> 
      </div> 
     </div> 
    </div> 
</body> 
</html> 
+0

它可以正常工作與其他網頁只有不會這樣。 相當於兩天前工作正常,而不是現在。 – Prathameshb7

+0

錯誤出現在第71行錯誤中,如果您已輸出一些HTML,則無法重新定位用戶。在所有內容之前,將$ _POST處理移至頁面頂部。我會更新我的答案。 – Daniel

+0

從現在開始,幾小時之後,我會提出這個問題,並在此刻搞砸了 – Prathameshb7

相關問題