Welcome Guest, Not a member yet? Register   Sign In
Problem with sending form data by Query string
#1

[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(){
  if(isset($_GET['CompanyName'])){
    $comName = $_GET['CompanyName'];
  }
  echo $comName;
}

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
#2

[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
#3

[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.
#4

[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)




Theme © iAndrew 2016 - Forum software by © MyBB