[eluser]wakextreme[/eluser]
[quote author="dgriffter" date="1196136425"]Hi,
I?m getting an error of undefined index when I try to select from my database using a $_POST variable.
The code in the controller is:
function search(){
$reference = $this->session->userdata($_POST['reference']);
$data['session_id']=$reference ;
$data['query4']= $this->db->query('SELECT * FROM product WHERE idreference="'.$reference.'"');
$this->load->view('search', $data);
}
My code in the form in the view file is:
<form action="<?php $_SERVER['PHP_SELF'] ?>" method="post">
<input type="text" name="reference" value="">
<input type="submit" name="Search" value="Search" />
</form>
Can someone please tell me where I'm going wrong, it's been driving me wild for ages...
Many thanks in advance...
Dgriffter[/quote]
I would try dumping out the contents of $_POST to ensure your data is coming through as expected and if it is then test the value of $reference.
Code:
echo '<pre>'; print_r($_POST); echo '</pre>';