0

i have the following button:

<form method="GET" action="/cms/deleteBlog/">
    <input class="btn btn-danger btn-small" type="submit" name="'.$blogID.'" value="Delete">
</form>

So right now i get the following url:

cms/deleteBlog/?1=Delete

obviously i want something like the following:

cms/deleteBlog/id=1

So i tried the following (which is obviously not working):

name="id='.$blogID.'"

So how do i solve this? i've been looking around on the internet, and i know the solution is quite easy. But i just can't remember the way how it is done!

Kevinvhengst
  • 1,672
  • 4
  • 27
  • 40

2 Answers2

3

Add a hidden form field.

<input type="hidden" name="id" value="1" />

Also, you should never use GET to delete or modify data. Read Why should you delete using an HTTP POST or DELETE, rather than GET? for insight.

Community
  • 1
  • 1
Daniel A. White
  • 187,200
  • 47
  • 362
  • 445
1

Why not use a hidden input field, e.g:

<form method="GET" action="/cms/deleteBlog/">
    <input type="hidden" name="id" value="'.$blogID.'">
    <input class="btn btn-danger btn-small" type="submit" value="Delete">
</form>

Or, if you want pretty URLs:

<form method="GET" action="/cms/deleteBlog/id='.$blogID.'">
    <input class="btn btn-danger btn-small" type="submit" value="Delete">
</form>
Rowland Shaw
  • 37,700
  • 14
  • 97
  • 166