Welcome Guest, Not a member yet? Register   Sign In
ctype_alnum($this->input->get('code', true)) not work?
#1

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

[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-gui...ereference
#3

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

[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));
#5

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

[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




Theme © iAndrew 2016 - Forum software by © MyBB