Prepared statements first
The database layer should never depend on a value being safe before it is used. Write queries with placeholders, bind parameters and keep SQL separate from input.
CSRF is about the request, not the user
A signed-in user can still be tricked into sending a request. A CSRF token ties a state-changing request to the user session. Verify it on the server for every POST, not only on selected forms.
Sessions need attention too
Use HttpOnly and SameSite cookies, regenerate the session ID on login, apply an idle timeout and re-check the user record when authorization matters.
Make the secure path the easy path
A small helper for CSRF fields and a consistent database method beat a long security checklist that developers forget under deadline pressure.