Welcome Guest, Not a member yet? Register   Sign In
Validation comments insert error
#1

[eluser]Asinox[/eluser]
Hi, i want to know the best way to validate form...
for example im trying to validate the comments form, but i have error, maybe because im wrong, but

for example the url for read article is:
Code:
http://localhost/ci/main/read/15.html

and "read function" hav the comments form, but when i trying to send the comment with the empty form the url come back without ID
Code:
http://localhost/ci/main/read/

and show a lot of error because need the ID for show the article....
the question is...

in which function i need to validate?, in the function "read"? of in the function "insert_comment"?

Thanks
#2

[eluser]Nathan Moore[/eluser]
The best way I have found to do validation is to run it in the same method as you use to display your content/form.

In your case, this would be the "read" function. Run the validation at the beginning of the function. If it returns false, show your page and form. If it returns true, the process the form.

As for passing your ID, I would just pass it through a hidden form value.
#3

[eluser]Asinox[/eluser]
Thanks Natahan




Theme © iAndrew 2016 - Forum software by © MyBB