1

I'm working in PHP to allow users to delete content and I want "delete" to be displayed in text(like a hyperlink) instead of a submit button, however, I don't want to use an actual hyperlink. Think how in most forums when you delete a comment it's generally text saying "delete comment" instead of a submit button.

I'd like to avoid using GET in this case because it's for deleting content. I understand OOP so I don't need an explanation of how it works.

Is there any way to do this with text saying "delete" (not a button) and then use objects to pass it to a function, instead of using a hyperlink to pass values?

Here's what I'm currently using to display the link, however, I use get to retrieve the values, which I would really like to avoid.

<td><a href="profile.php?userid='<? echo $request['userid']; ?>'&action=delete"><? echo $request['username']; ?></a></td>

<td><a href="profile.php?userid='.    $requestID['userID'].'">Delete</a></td>
user1104854
  • 2,137
  • 12
  • 51
  • 74

1 Answers1

3

Since GET is to get/retrieve data, you should use POST to POST updates to the server (i.e. deleting a record).

  • You can either use a submit button, and style it to look like a link in CSS (best)
  • Or you could use an actual hyperlink and use JavaScript/jQuery to submit it for you to the server (not ideal).

I suggest you use the first one if you must use links. However, there's nothing wrong with using <button>s:

  • Semantically, hyperlinks are supposed to lead the user to a different page, where a button is supposed to make something happen.
  • It makes more sense to use a button rather than a link in this case.

Please consider that.

Madara's Ghost
  • 172,118
  • 50
  • 264
  • 308
  • 1
    lol i love the "please consider that", as if a polite way of saying "please dont make it a headache for the other guy" +1.. oh and what @Truth says is ... the truth lol – NDBoost Apr 10 '12 at 21:00
  • I guess I'll just use a submit button and disguise it as text – user1104854 Apr 10 '12 at 21:01