Q&A
最近cakephp3.4.8をインストールして使い始めたところです。
formで送信すると
Cannot modify header information - headers already sent by
のエラーと
Unable to emit headers. Headers sent in file=/Applications/MAMP/htdocs/cake/vendor/cakephp/cakephp/src/Error/Debugger.php line=921 [CORE/src/Http/ResponseEmitter.php, line 48]
のエラーが表示されてしまいます。
viewではRegistsフォルダの中にindex.ctpを作り
html
1<div class="row"> 2 <form method="post" action="/cake/regists/regist"> 3 <input type="text" name="product"> 4 <button type="submit" id="btn">送信</button> 5 </form> 6</div>
RegistsController.phpは
php
1<?php 2namespace App\Controller; 3 4use Cake\Core\Configure; 5use Cake\Network\Exception\ForbiddenException; 6use Cake\Network\Exception\NotFoundException; 7use Cake\View\Exception\MissingTemplateException; 8use Cake\ORM\TableRegistry; 9use App\Controller\AppController; 10use Cake\I18n\Time; 11 12 13class RegistsController extends AppController{ 14 public $name="Regists"; 15 public $autoRender=true; 16 17 public function index(){ 18 }//index 19 20 21 public function regist(){ 22 $product=$this->request->data["product"]; 23 debug($product); 24 }//regist 25 26}//RegistsController 27?>
としていて、header関数も使っていないのですが、それとはまた違うエラーなのでしょうか?
debugを消すとエラーもなくなります。
このエラーをなくすにはどうしたら良いでしょうか?
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー
下記のような回答は推奨されていません。
このような回答には修正を依頼しましょう。
2017/06/26 06:14
2017/06/26 06:16
2017/06/26 06:33
2017/06/26 06:36
2017/06/26 07:01