CodeIgniter Forums
Validation comments insert error - 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: Validation comments insert error (/showthread.php?tid=10327)



Validation comments insert error - El Forum - 07-27-2008

[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


Validation comments insert error - El Forum - 07-27-2008

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


Validation comments insert error - El Forum - 07-27-2008

[eluser]Asinox[/eluser]
Thanks Natahan