Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7026781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:09:46+00:00 2026-05-28T00:09:46+00:00

Is it better to validate user input before it’s sent to the server with

  • 0

Is it better to validate user input before it’s sent to the server with JS or server side with PHP? Or maybe it’s worth doing both just to be on the safe side?

I’m creating a site (very simple at the moment) that has a members area/admin area/etc. At the moment i only have user input of Username and Password, in the future there will be more (email, address, etc), but whats the best practice of checking the data?

Do i throw a load of ‘if…else’ statements at it until the user gets it right? Or maybe have separate variables for each value entered by the user and set it to true or false if it’s correct or wrong? (like e-mail validation to make sure it’s in an email format)

There are a lot of ways to do it, but which ones you would suggest? I don’t want to be writing 50 lines of code when i could do the job in 10 lines…if that makes sense :p

Any help would be appreciated, thanks! 🙂

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T00:09:47+00:00Added an answer on May 28, 2026 at 12:09 am

    Server-side validation is a must, client-side validation is a plus.

    If you only use client-side validation, nefarious people will hack your system to post un-validated stuff – breaking your scripts, and potentially exploiting your system. This is very bad from a security standpoint.

    That said, you should also include client-side validation, since that’s much quicker than a round trip to the server, and gives your users instant feedback. This’ll keep your users happy, and will have them coming back to your site.

    So, if possible, use both. If you can’t/won’t, then at least do it server-side. Client-side-only validation is a recipe for disaster!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have form who validate user input, I use PHP, Javascript and AJAX. I
I'm trying to practice writing better code, so I wanted to validate my input
I want to validate user input on a Web Form, like valid numbers, date
Is it generally better practice (and why) to validate attributes in the model or
Which class design is better and why? public class User { public String UserName;
I have a problem when using a user input method which allow validates the
I need to validate a control input on losing focus. Normally I'd use the
After my form.Form validates the user input values I pass them to a separate
How to validate a TextBox field against a Natural Number ? User are restricted
I've got a wizard which needs to validate if a user is logged in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.