2017-08-09 80 views
0

我想問一下關於CI的html請求,所以我有一些問題。使用http請求和重定向使用ci

  1. 我有例如數據視圖
<?php 
     foreach($data_gw as $user){ 
    ?>  
     <td><?php $user->dt_request_pod; ?></td> 
    <?php } ?> 
<br> 
    <?php 
    $test_time = $user->dt_request_pod; 
     ?> 
<br> 
    <?php 
    $new_time = date('Y-m-d H:i:s',strtotime('1 seconds',strtotime($test_time))); 
    echo $new_time; 
    ?> 

,現在我想的是$ NEW_TIME變量(使用重定向CI),並讓我的控制器上的變量示例

redirect('localhost/2ndpage.php?id=123')

  • 後得到的是變量i想和鏈接例如HTTP請求
  • http://abcde.com/api/pod/gettrackpartnerresi?key=CD8B025D3335477A8C779FB8BC65FEB8&afterdatetime=2017-07-13

    許多感謝您的幫助

    +0

    你嘗試過使用會話? – Jok3r

    +0

    還沒有,但我使用會話登錄表格 –

    +0

    確定爲$ test_time設置會話變量,例如$ this-> session-> set_userdata($ test_time),並通過應用$ session_value = $ _SESSION訪問會話數據$ test_time]你可以通過該變量URL – Jok3r

    回答

    0

    固定我有其他的方式

    在控制器上

    > public function get_date($new_time) { 
    > 
    >  $data1['mydate'] = $new_time;  $this->load->view('menu'); 
    >  $this->load->view('page1',$data1); 
    > 
    > 
    >  ////test json request 
    > 
    > $data = array 
    > 
    > (
    >   'cabang'  => '1', 
    >   'key' => 'a', 
    >   'kode_cabang' => 'b', 
    >   'kodecaodoo'=> '', 
    >   'kodestatus'=>'', 
    >   'name'=>'', 
    >   'noresi'=>'', 
    >   'note'=>'', 
    >   'trackingdatetime'=>'' 
    >  ); 
    > 
    >  $data_string = json_encode($data); 
    > 
    >  $curl = curl_init('http://mysite.com.ap-southeast-1.compute.xxx.com:8084/api/pod/gettrack'); 
    > 
    >  curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "POST"); 
    > 
    >  curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    >  'Content-Type: application/json', 
    >  'Content-Length: ' . strlen($data_string)) 
    > ); 
    > 
    >  curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); // Make it so the data coming back is put into a string 
    >  curl_setopt($curl, CURLOPT_POSTFIELDS, $data_string); // Insert the data 
    > 
    >  // Send the request 
    >  $result = curl_exec($curl); 
    > 
    >  // Free up the resources $curl is using 
    >  curl_close($curl); 
    > 
    >  echo $result; 
    > 
    > 
    > 
    > } 
    

    然後在我看來只是張貼

    回聲$指明MyDate