php - Codeigniter pass value from URL -
function receives departure date , adult view page ( passes value correctly have checked doing echo function ) , function not able pass values function
public function index() { if ($data = $this->input->post('muktinath')) { $date = $data['departure_on']; $adult = $data['adult']; $getnamevalue = array( $date = 'departure_on', $adult = 'adult', ); redirect('booking/muktinath/' . $getnamevalue); } else{ $this->load->view('index'); } }
this function must receive value
public function muktinath($getnamevalue) { echo $getnamevalue; // here value must shown of departure date , adult passed above }
you didn't share error messages getting. bet there several.
the biggest issue cannot put array
part of query string. fix pretty easy.
function index() { $data = $this->input->post('muktinath'); if($data) { //from question $data seems array already. use that! redirect('booking/muktinath/'.$data['departure_on'].'/'.$data['adult']); } else { $this->load->view('index'); } }
your function receives values defined way.
public function muktinath($date, $name) { echo $date . " - " . $name; }
you will have problem if $date
contains slashes (/) in assume date string. slashes become part of url which, if date "7/9/2016" , name "sandesh" make url.
http://example.com/booking/muktinath/7/9/2016/sandesh
as can see, has several more uri segments expecting. url echo "7 - 9" not helpful. might have adjust format of date while sending , reformat after received muktinath()
.
by way, array declaration wrong. think trying make this.
$getnamevalue = array( 'departure_on' => $date, 'adult' => $adult );
the thing is, have recreated $data
was. don't need $getnamevalue
anyway.
Comments
Post a Comment