Jump to content

gettting a single value to post from a while loop to delete the corrisponding


son.of.the.morning

Recommended Posts

i have a while loop that builds up a table of records, each row has a button that needs to have an action to delete that specific record. I can think of the obvious way around this and add a form around each row and set the button to type="submit". However there is a problem i have the entire table of records wrapped within in a form object for other functionalities.

 

Does anyone have a solution for this problem?

Link to comment
Share on other sites

You could have an anchor instead that creates a link to a delete script, like:

 

<a href="./?action=delete&id=1">Delete</a>

 

Whenever I use this kinda of functionality, im careful to do a header(location: "./") redirect as soon as the function completes successfully so that people cant refresh and have the function execute multiple times.

Link to comment
Share on other sites

You should just use a link (and technically if you follow REST practises that is how you should do it - through the URL).

 

If you're worried about tampering with the URL to delete other items, then surely they user could just go back and click the button on the item they wish to delete? Permission checks should prevent them deleting anything they shouldn't be able to.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.