Problem with sending form data by Query string |
[eluser]Unknown[/eluser]
Hi, I have form which is having one text field, named by CompanyName. when I submit the form it submitting as query string (form method is GET )as i want. The following is sample URL for that : http://localhost/index.php/Companysearch...me=Darwish I'm trying to get CompanyName within my result function as follows: Code: function result(){ My problem is that, it says $comName is undefined variable. Is there any wrong in my code?. or can't we use like above? Please guide me how to sort out this Nisal
[eluser]MASS MASS[/eluser]
first you check with following echo $_GET['CompanyName']; if result is Darwish....... use below code function result() { $var = $_GET['CompanyName']; if(isset($var)) { $comName = $_GET['CompanyName']; } echo $comName; } else $_GET is not retreiving any data
[eluser]Jatinder Thind[/eluser]
$_GET won't work in CI. You will have to use POST. Or change Code: $config['enable_query_strings'] = FALSE; to Code: $config['enable_query_strings'] = TRUE; in config.php to enable query strings.
[eluser]MASS MASS[/eluser]
better to use post method as below $this->input->post('fieldname',TRUE) or get method as below $this->input->get('fieldname',true) |
Welcome Guest, Not a member yet? Register Sign In |