shadiadiph Posted February 20, 2009 Share Posted February 20, 2009 Where can I read up on building a php form validation script for my forms? I have been using a javascript validator for years now but i think it is time to make my own as javascript is messy i think. Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/ Share on other sites More sharing options...
Yesideez Posted February 20, 2009 Share Posted February 20, 2009 One of the advantages of using Javascript is it helps reduce the load on the server. However, checks should still be made within PHP because the Javascript checks can easily be bypassed. If you're not checking with PHP then this opens all sorts of doors for anyone wantng to cause you harm. If you want to validate your forms the best way is to download some scripts and play with them. Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767104 Share on other sites More sharing options...
shadiadiph Posted February 20, 2009 Author Share Posted February 20, 2009 I have been looking at a few but none that seem nice and easy to understand I am not a fan of php self command but moreso not a fan of javascript Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767108 Share on other sites More sharing options...
premiso Posted February 20, 2009 Share Posted February 20, 2009 AJAX would be my way. Then you can use the same PHP functions when you are posting the data, redundant but if you want easy error display so they can fix it without a page reload that is the way to do it. Take a look into that, that way you code the PHP functions use AJAX to call those functions then on the posting PHP portion you can re-validate the data easily. Server load will not be an issue at all, so do not even worry about that. Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767114 Share on other sites More sharing options...
shadiadiph Posted February 20, 2009 Author Share Posted February 20, 2009 thanks for the heads up premiso sounds good my only previous knowledge of AJAX until recently is that it is a bathroom cleaner from the UK. I have only started hearing that it's now also the name of another computer language. Can you reccomend any places to start learning AJAX ? Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767129 Share on other sites More sharing options...
shadiadiph Posted February 21, 2009 Author Share Posted February 21, 2009 I have noticed alot of comments on the net that AJAX isn't cross browser firendly alot of people say it doesn;t function properly in Opera? Also it is a javascript so surely it will not work if someone has javascript disabled?? Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767793 Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 Exactly. AJAX solutions are nice, but they rely on javascript. It's best to always have PHP, and its nice to add javascript/AJAX solutions. Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767797 Share on other sites More sharing options...
shadiadiph Posted February 21, 2009 Author Share Posted February 21, 2009 I have been looking for a good example of php form validation they are all so different the ones I have looked at don't know where to go with it seems similar to javascript validation need an if statment for each input field. I have also looked at quite a few AJAX demos and not one fo them works properly I just had one that where I entered @yahoo as the email and it tld me it was valid also nearly all of them if i leave them blank and just click submit they allow the user to submit so i am not impressed with any of the ones I have seen so far anyone know of any good examples of php or ajax Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767806 Share on other sites More sharing options...
haku Posted February 21, 2009 Share Posted February 21, 2009 I write my own, so I don't have a particular link to give you. But basically you want to check each field for specific stuff. For example, if its email, you want to check to make sure it's an email address. You want to user regex (regular expressions) for this. Google 'email regex' and 'email field validation' to get some ideas on how to put this together. I believe there are even regex library sites out there. If you are validating a name field, you want to check if its alphanumeric, and allow probably spaces, single quotes, and hyphens. Addresses are alphanumeric, hyphens, and spaces etc. Google each type of field as you validate it. You will probably also want to check length (both min and max) and make sure they are not empty. Just take each field one at a time, figure out what things you want to validate, then google that specific type of validation. It will be slow going, but you'll get it over time. Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767814 Share on other sites More sharing options...
shadiadiph Posted February 21, 2009 Author Share Posted February 21, 2009 ok thanks I will give it a go each input field has to have its own error message seems simple enough i guess i can add a required="yes" or "no" and validation="alpha" "numeric" etc I am used to slow just spent most of last week sending over 500 emails to myself to get an emailing files thingy working Quote Link to comment https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767819 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.