Writing php validation functions that can be used by jquery
Posted: Wed Feb 23, 2011 3:34 pm
Basically I'm trying to teach myself php and I have been looking into membership systems (so login form, registration form, etc.) and how to validate these forms. As I understand javascript can be used to give live feedback to the user about the data they are entering into the form. However, my research has shown that most of the time this validation is done independantly from the server-side validation and so there are two validation scripts (one javascript and one php). I only want one validation script and this is obviously going to be php. However, I would like to know how to write the functions so that they can be combined with javascript to give live feedback. I understand this can be achieved through ajax, to call the php function and alter the html in real-time. I have found a tutorial describing how to do just that:
http://jqueryfordesigners.com/using-aja ... ate-forms/
This makes use of the jquery library for the ajax calls which I thought was quite nice. However, I am completely stumped on the php front as this is not included in the tutorial. Completely ignoring javascript, how are validation functions similar to this (i.e. using arrays to output error messages) implimented in the php form? So far I have been dealing with functions that output either true or false based on a tutorial for a complete user login system:
http://www.ineedtutorials.com/code/php/ ... p-tutorial
Unfortunately this code does not output error messages. Essentially I am trying to combine the two tutorials. I want a system that has one validation script that can function without javascript but can be used by javascript to add to the UI experience if it is enabled.
If anyone could help or point me to a better tutorial I would be so greatful. Many thanks.
http://jqueryfordesigners.com/using-aja ... ate-forms/
This makes use of the jquery library for the ajax calls which I thought was quite nice. However, I am completely stumped on the php front as this is not included in the tutorial. Completely ignoring javascript, how are validation functions similar to this (i.e. using arrays to output error messages) implimented in the php form? So far I have been dealing with functions that output either true or false based on a tutorial for a complete user login system:
http://www.ineedtutorials.com/code/php/ ... p-tutorial
Unfortunately this code does not output error messages. Essentially I am trying to combine the two tutorials. I want a system that has one validation script that can function without javascript but can be used by javascript to add to the UI experience if it is enabled.
If anyone could help or point me to a better tutorial I would be so greatful. Many thanks.