0

all.

I've been trying to create an admin area for a website, and I've encountered a strange issue.

I wish to create a table with 'edit' and 'delete' buttons for each entry, so that an admin can edit the database.

The 'edit' button has a link which changes depending on the artist id in the database.

However, for some reason, when I click on an edit button, what gets appended to the link isn't what is in the form, I instead get something like : e0=Edit.

I've no idea what causes that. I've also tried Button forms, they seem to have similar effects. I didn't have any problems with the delete button because it didn't redirect to another page.

Here's one row for the table (the initial comes from code elsewhere) :

<form method="link" action="edit-artist.php/?aid='.$data['aid'].'">
    <input type="submit" name = "e'.$count.'" value="Edit" />
            </td><td>
</form> 

The html code generates all right, but the only thing I find in the GET array (and that gets in the URL is e0=>edit (or e whatever => edit, depending where I click).

Do I have the wrong approach for this kind of problem ? Where is my mistake, anyway ?

Thanks in advance, Spliblib.

P.S : I apologise if this problem has already been submitted, however the terms are so generic I had some trouble finding anything similar.

spliblib
  • 43
  • 5

1 Answers1

0

The data in the form is being transformed into GET parameters...

so...

 <input type="submit" name = "e'.$count.'" value="Edit" />

becomes

edit-artist.php/?e0=edit 

because there is an attribute e(count) with the value edit.

May I suggest you just use a link instead...

<a href="edit-artist.php/?aid='.$data['aid'].'">Edit</a>

UPDATE:

Alternatively try

<form action="edit-artist.php">
    <input type="hidden" name="aid" value="'.$data['aid'].'" />
    <input type="submit" value="Edit" />
</form> 
Andy
  • 341
  • 1
  • 11
  • I see what you mean, I feel a bit silly. But how do I wrap that out around a button properly ? What kind of form is appropriate for what I want ? A plain link is fine, really, but I would like to know the proper syntax. It'd also be useful for whoever ends up on this link. – spliblib Aug 21 '14 at 10:11
  • Either Style with CSS or alternatively change it to update in answer... Personally I'm not a fan of using forms for GET data, I prefer styled links. – Andy Aug 21 '14 at 10:13
  • See: http://stackoverflow.com/questions/710089/how-do-i-make-an-html-link-look-like-a-button for styling. – Andy Aug 21 '14 at 10:17
  • Your second suggestion only adds a '?' at the end of the URL. It redirects to edit-artist.php?. Thanks for all the replies everyone. – spliblib Aug 21 '14 at 10:25
  • Ah OK, two seconds... Try that, it's been a while since I did this using Forms instead of links – Andy Aug 21 '14 at 10:28