r/PHPhelp • u/MyYoutubeIsKuroro • Sep 17 '21
Making PHP more secure
For example a blog website. Is there a way to delete a certain blog that won't need to put a hidden input field containing the id of that blog?
For example:
<form> <input type="hidden" value="<?= $blogId; ?>"> (This is the part I want to remove from my code) <button>Delete</button </form>
On some programming languages such as nodejs, there is no need to do that. Thats why Im asking here if there is also a way in PHP to not do that.
EDIT: Thank you to everybody that answered my question.
7
Upvotes
1
u/itemluminouswadison Sep 17 '21
How else can you know which blog to delete? You usually send along the id in the request
You could post a hash and lookup using that instead
Or post to itself since the blog id is already in the current page route
You could use sessions to persist the last viewed blog id but that's dangerous