這個我確定是一個簡單的忽略,但它在短時間內給了我很頭疼的問題。無法在codeigniter中發佈簡單的表單日期
我試着從這個觀點發布的數據:
<?php
if (!$this->tank_auth->is_logged_in())
{
echo "<a href='index.php/auth/login'>Login</a>";
} else { ?>
<form method="POST" action="create_community">
<label>Community Name: </label><input type="text" name="communityname" value="231"/><br>
<label>Description: </label><br><textarea name="communitydesc"></textarea><br>
<label>Image Location(URL): </label><input type="text" name="imageloc"/><br>
<input type="radio" name="privacy" value="public" /> public<br />
<input type="radio" name="privacy" value="private" /> private<br />
<input type="radio" name="privacy" value="business" /> business<br />
<input type='submit'/>
</form>
<?php }
?>
創建控制器如下:
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Create extends CI_Controller {
function __construct()
{
parent::__construct();
$this->load->library('tank_auth');
$this->load->library('encrypt');
$this->load->library('session');
$this->load->model('topbar_model');
$this->load->model('left_model');
$this->load->model('right_model');
/*
$this->load->model('right_model');
$this->load->model('left_model');
$this->load->model('topic_model');
*/
$this->load->helper('url');
$this->load->helper('form_helper');
$this->load->helper('form');
$this->load->helper(array('form', 'url'));
$this->load->library('form_validation');
$this->load->library('security');
$this->load->library('tank_auth');
$this->lang->load('tank_auth');
}
public function index()
{
$this->load->view('create_community');
}
public function create_community()
{
$this->load->view('templates/head');
echo "testing";
print_r($this->input->post());
}
}
create_community顯示 「測試」,但不顯示職位。我嘗試過發佈個人輸入內容,並且什麼也沒得到。
任何想法?
剛剛看到了一些東西:我的視圖和函數名字一樣...沒有做任何事情 –
你可以嘗試在'index.php'中添加'error_reporting(E_ALL)'並查看是否有錯誤? – Touki
嘗試'print_r($ this-> input-> get_post());'檢查瀏覽器是否服從表單的method =「POST」'。另外,使用Firebug或Chrome開發者控制檯,檢查網絡標籤以查看瀏覽器是否確實發送了發佈數據。你也可以嘗試'print_r($ _ POST);'和'print_r($ _ REQUEST);'來檢查表單數據是否到達PHP端。 –