2016-05-12 5 views
0

私はfrontend angularjsとbeckend codeignitor(3)を使用しています。 バックエンドコントローラにデータを投稿したいと思います。 しかし、私はデータを取得できません。ここでcodeigniter3コントローラでPOSTデータを取得する方法

は私のHTML-は、誰かが私を助けることができればここで

$scope.submitForm = function(table) { 
    $http.post("http://localhost/DatabaseApp/welcome/getData/",table) 
     .success(function(response) {$scope.data = response}); 
} 

機能 - 私のangularjsコントローラだから

function getData() 
{ 

     $table_column =  $this->input->post('table_column'); 
     $table_name =   $this->input->post('table_name'); 
     $table_value =  $this->input->post('table_value'); 
     $table_where =  $this->input->post('table_where'); 

    print_r($table_name); 

} 

機能 - 私のcodeignitorである。ここで

<form> 

      <fieldset class="form-group"> 
      <h3>Get data of your table</h3> 
       <label for="exampleInputPassword1">Select coloumn value</label> 
       <input type="text" class="form-control" ng-model="table.table_column" id="exampleInputPassword1" placeholder="table coloumn values"> 
       <small class="text-muted">Please enter valid data.</small> 
       </fieldset> 
       <fieldset class="form-group"> 
       <label for="exampleInputEmail1">Enter Table Name</label> 
        <input type="text" ng-model="table.table_name" class="form-control" id="exampleInputEmail1" placeholder="Enter Table Name"> 
       <small class="text-muted">Please enter valid table name.</small> 
       </fieldset> 

       <fieldset class="form-group"> 
       <label for="exampleInputPassword1">Where</label> 
       <input type="text" class="form-control" ng-model="table.table_where" id="exampleInputPassword1" placeholder="Where"> 
       <small class="text-muted">Please enter valid value</small> 
       </fieldset> 
       <fieldset class="form-group"> 
       <label for="exampleInputPassword1">Value</label> 
       <input type="text" class="form-control" ng-model="table.table_value" id="exampleInputPassword1" placeholder="Table Value"> 
       <small class="text-muted">Please enter valid value</small> 
       </fieldset> 

       <button type="submit" class="btn btn-primary" ng-click="submitForm(table)">Submit</button> 
      </form> 
    </div> 

です私は感謝しています。どうもありがとう。

文字列はあなたが使用する必要がありますので、ストリーミングとして$ HTTP角度が要求データを送信するので、あなたは$ _POST配列を使用してデータを取得することはできませんもちろんの
+0

入力の名前 – praguan

答えて

0

$data = file_get_content("php//input"); 
$data = json_decode($data); 
    $table_column =  $data->table_column; 
    $table_name =   $data->table_name; 
    $table_value =  $data->table_value; 
    $table_where =  $data->table_where; 

幸運

0

1)を追加するべきフォームタグにmethod="POST"action="~/nameController/nameAction"

2)あなたの入力に名前を付けてください。

<form method="POST" action="~/nameController/nameAction"> 
<input type="text" name="exampleInputPassword1"/> 
<!--You code here--> 

</form> 
関連する問題