0

I am still learning CodeIgniter , how as add uri->segement from value input?

<form action="getdata" method="GET">
    <input name="id" type="text" value=""/>
    <input name="month" type="text" value=""/>
    <input name="submit" type="submit" value="Submit"/>
</form>

Example

name("id") = 001
name("month") = Feb

Result

<form action="getdata/001/feb" method="GET">
    <input name="id" type="text" value=""/>
    <input name="month" type="text" value=""/>
    <input name="submit" type="submit" value="Submit"/>
</form>
Smern
  • 18,746
  • 21
  • 72
  • 90
Duwi irwanto
  • 137
  • 1
  • 3
  • 12

3 Answers3

0

You can get values from URL by using CI URI Class

Example:

<form action="getdata/001/feb" method="GET">
    <input name="id" type="text" value="<?=$this->uri->segment(2)?>"/>
    <input name="month" type="text" value="<?=$this->uri->segment(3)?>"/>
    <input name="submit" type="submit" value="Submit"/>
</form>

Here:

$this->uri->segment(2) will return ID (001) and
$this->uri->segment(3) will return Name (Feb)

devpro
  • 16,184
  • 3
  • 27
  • 38
0
 <?php $ci =& get_instance(); ?>
<form action="getdata/001/feb" method="GET">
 <input name="id" type="text" value="<?=$ci->uri->segment(2)?>"/>
 <input name="month" type="text" value="<?=$ci->uri->segment(3)?>"/>
 <input name="submit" type="submit" value="Submit"/>
</form>

get_instance() in Codeigniter: Why assign it to a variable?

Community
  • 1
  • 1
channasmcs
  • 1,104
  • 12
  • 27
0

Are you after something like

if (id == 001 && month == Feb) {
 do something;
} else {
do whatever?;
}