Skip to content
Advertisement

How to let user only delete their details and no one elses php

I created a very basic site where a user logs in and then has access to a table that they can edit. I want the user to be able to only delete their own details and no one elses, and I don’t know what i’m supposed to add to the delete page so it only deletes the details of logged in user and doesn’t delete anyone else’s. At the moment it doesn’t delete any details.

This is my register page

And this is my login page

This my contact page

and finally my delete page

Advertisement

Answer

What you need to do is to add session_start() function on the above of the delete page

  • use this $_SESSION[“id”] session as you have assigned in login page
  • always check / compare logic before doing any operation so your code will be remain small, smart, simple ,readable and fast.
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement