How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?

How to safely pass post_id and user_id via AJAX to the backend (prevent user from changing it via JS)?

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)