How to prevent adding data to a localhost database after refresh?

I fixed it with using header("Refresh:0");

This allows the page to be refreshed immediately after the if statement has been processed, allowing the page to not resend the data that was inserted before.

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