0

I am wondering about the right way of validating data on client and server side.

I have spreadsheet, made with JExcel addon, and I have to check if any user has changed headers. Spreadsheet data is generated using pivot function in database, so the column count and order would vary.

I locked all possibilities of headers editing by ordinary users, but if someone knows how to use console, it may be unlocked. The pivot is similar to the picture below:

enter image description here

The JExcel loads data from dynamic JSON generated by PHP script. I can calculate "checksum" for header order, but how to validate it when user will update spreadsheet? I have to validate if user sends spreadsheet based on the same pattern. How to do it in best way?

EDIT:

I created process logic:

  1. When the data is called by the user, php generates datahash and assigns it to the php session_id.
  2. Session_id is coded into md5 as well as datahash and all is saved to mysql database.
  3. The datahash is passed via http headers with ajax response (to deliver hash for the client-side verification)
  4. After the data is sent back, server reads all hashes generated within current php session.
  5. If any hash matches - data is valid. This solution is good, because I only need info if this data has been sent to user.
3
  • 1
    Best way? Make an attempt and put it on Code Review and they might optimize it for you. Commented Nov 28, 2019 at 0:01
  • Get hash values from all cells and compare before save Commented Nov 28, 2019 at 1:43
  • My process logic is to validate it with mysql hashes. Description in edited init post. Commented Nov 30, 2019 at 2:47

1 Answer 1

1

You can use some JWT to sign your data in the server-side.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.