validation: PHP vs JAVASCRIPT

  • buzzby365
  • Proficient
  • Proficient
  • buzzby365
  • Posts: 288

Post 3+ Months Ago

which is best. javascript seems to be real easy to implement while my experiences with php havent been fruitful at all. javascript validation can be in a HTML file aswell as in a PHP file. so will turning the javascript off affect the PHP or HTML file or neither. i know that when you view source in a php file it returns exactly what you would see in a html file.

is there a simple php validation out there? someting to validate the fields irrespective of how the php file is. ie if the php file actually redirects to itself after the form is sent (the action is the same php file as the form)

sorry to sound confusing to some but i amreally not having a good day of it and i need some good sound validation that will not blank out my form upon submission which is what has been happening via php validation and javascript validation.
  • rtm223
  • Mastermind
  • Mastermind
  • User avatar
  • Posts: 1855
  • Loc: Uk

Post 3+ Months Ago

Um I am not sure what you are asking but IMO, both methods have their strengths and weaknesses

JS means you don't have to refresh the page every time someone makes a mistake, you can also use alerts to prevent confusion. But if the user turns it off then you have no guaruntee of getting valid data.

<b>Ideally</b> you should validate at both ends. Validate using javascript to prevent the refreshes, but use PHP as well to make sure that nothing is going wrong. Of course I say ideally because it would be a pain in the ass to create duplicate form validation on both sides, and keep both the javascript and PHP checking in the exact same way. unless of course you could develop a way of generating the javascript checker from php variables and use the <b>same</b> variables to validate using php. But sounds like a lot of work to me.....

that will not blank out my form upon submission which is what has been happening via php validation

Well for that you have to use the get/post varibles and insert them back into the form. It should only take a moment to implement.

Post Information

  • Total Posts in this topic: 2 posts
  • Users browsing this forum: No registered users and 20 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum

© 1998-2017. Ozzu® is a registered trademark of Unmelted, LLC.