Jump to content

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767104
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767114
Share on other sites

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 ?

Link to comment
https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767129
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767806
Share on other sites

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.

Link to comment
https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767814
Share on other sites

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

Link to comment
https://forums.phpfreaks.com/topic/146111-form-validation/#findComment-767819
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.