I am trying to get data from html form in php. this is my html code.
<div id="search_specify">
<?php echo form_open('search/advanced_search');?>
<a class="srch_heading">Keyword</a>
<input name="key" class="srch_box" type="text" />
<br />
<br />
<a class="srch_heading">First Name</a>
<input name="first" class="srch_box" type="text" />
<br />
<br />
<a class="srch_heading">Last Name</a>
<input name="last" class="srch_box" type="text"/>
<br />
<br />
<a class="srch_heading">Company</a>
<input name="company" class="srch_box" type="text"/>
<br />
<br />
<a class="srch_heading">Country</a><br />
<select name="country" class="slct_box"/>
<option>aaa</option>
</select>
<?php echo form_submit('submit','Search') ?>
</div>
this is my php code
$key=$_POST['key'];
$first=$_POST['first'];
$last=$_POST['last'];
$company=$_POST['company'];
$country=$_POST['country'];
echo $first;
echo $last;
echo $company;
echo $key;
echo$country;
the values of key, company and country are read fine but the code did not get the value of first and last
This the the page source code
<form action="http://localhost/ok/index.php/search/advanced_search" method="post" accept-charset="utf-8"><a class="srch_heading">Keyword</a>
<input name="key" class="srch_box" type="text" />
<br />
<br />
<a class="srch_heading">First Name</a>
<input name="first" class="srch_box" type="text" />
<br />
<br />
<a class="srch_heading">Last Name</a>
<input name="last" class="srch_box" type="text"/>
<br />
<br />
<a class="srch_heading">Company</a>
<input name="company" class="srch_box" type="text"/>
<br />
<br />
<a class="srch_heading">Country</a><br />
<select name="country" class="slct_box"/>
<option>aaa</option>
</select>
<input type="submit" name="submit" value="Search"/></div>
</form>
Please help
I was not closing the form. That was causing the trouble. So i added <?php echo form_close();?>
after <?php echo form_submit('submit','Search') ?>
And problem solved!
You can try this code in you php file.
echo $this->input->post('first');
It will give your all post data.