anthr
anthr

Reputation: 1036

Problem with html 'post' button in a table, using PHP

I am relatively new to html and PHP, and have a problem which I can't seem to get around.

Basically, I have a table and want to have within one of the cells a submit button that will take the user to another page where they can edit that row.

I have all of the machinery for this in place, apart from the fact that I can't get the button to send the user to the new page, it just posts the variable to the same page.

The relevant code is:

 if ($Started==0){
      $TABLE.="<td align='center' width=220><font size='2'>Evaluation not yet available.<br><br>";
      $TABLE.="<form action='request.php' method='post' style='margin:6; text-align:center;'><INPUT TYPE='submit' NAME='toedit' VALUE='Edit'></FORM>";
    } 

Where request.php is another page (which is working, and another form button (a link) works fine with this button. On submitting, however, the page with the submit button reloads with the extra text:
?Run_form_in=420&toedit=Edit in the address.

Started is just a condition set at either 0 or 1, and works fine.

Thanks in advance!

Upvotes: 0

Views: 520

Answers (2)

aularon
aularon

Reputation: 11110

Check for parent <form> tags, they cause such problems. :)

Upvotes: 0

shamittomar
shamittomar

Reputation: 46692

Change your form method from POST to GET in the third line and the problem will be solved:

$TABLE.="<form action='request.php' method='GET' style='margin:6; text-align:center;'><INPUT TYPE='submit' NAME='toedit' VALUE='Edit'></FORM>";

Upvotes: 1

Related Questions