CodeIgniter Forums
ctype_alnum($this->input->get('code', true)) not work? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: ctype_alnum($this->input->get('code', true)) not work? (/showthread.php?tid=42409)



ctype_alnum($this->input->get('code', true)) not work? - El Forum - 06-06-2011

[eluser]helloworld7[/eluser]
Hi. I'm doing a check to see if the get input is alpha numeric but I get this error. Anyone know how I can resolve this or there's a way to validate?

Fatal error: Can't use function return value in write context

Thanks.


ctype_alnum($this->input->get('code', true)) not work? - El Forum - 06-06-2011

[eluser]LuckyFella73[/eluser]
Use CI Form Validation Class and set the matching rule like:
Code:
$this->form_validation->set_rules('input_field_name', 'Your Input Field Title', 'alpha_numeric');

Don't forget we have the very helpfull User Guide!
http://ellislab.com/codeigniter/user-guide/libraries/form_validation.html#rulereference


ctype_alnum($this->input->get('code', true)) not work? - El Forum - 06-06-2011

[eluser]helloworld7[/eluser]
Sorry I didn't put enough info. That is actually from the query string. And it seems the form validation only for form inputs. I tried this with the input->get but it saying undefined index.

Is there a validation class for input->get? If not how can I do alpha_numeric check for input->get data?

Thank you.


ctype_alnum($this->input->get('code', true)) not work? - El Forum - 06-06-2011

[eluser]theprodigy[/eluser]
What happens if you use
Code:
$code = $this->input->get(‘code’, true);
ctype_alnum($code);
instead of
Code:
ctype_alnum($this->input->get(‘code’, true));



ctype_alnum($this->input->get('code', true)) not work? - El Forum - 06-07-2011

[eluser]LuckyFella73[/eluser]
Quote:I tried this with the input->get but it saying undefined index.

Did you enable query strings? I guess all get data is filtered otherwise.
By default the GET array is destroyed before a controller is called.


ctype_alnum($this->input->get('code', true)) not work? - El Forum - 06-07-2011

[eluser]helloworld7[/eluser]
Hi. It seems it works using this. preg_match("/^[A-Za-z0-9]+$/", $code)

I guess this is more a problem in php side instead. Thank you for your help. Smile