Wrong variable being passed in PHP form
Here is my code:
echo "<table class='forum'>
<tr>
<td class='forum'><b>Enter Response Here:</b></td>
</tr>
<form action='a_insert.php?id=" . $answerid . " method=post>
<tr class='forum'>
<td class='forum'><textarea rows='5' cols='80' name='cBody'></textarea></td>
</tr>
&l开发者_如何学运维t;tr class='forum'>
<td><input type='submit' value='submit'></td></tr>
</form></table><br><br>";
It's currently passing "cBody" instead of $answerid like I want it to. How do I fix this?
Thanks everyone for their help.
You should add that id as an input in the form, not part of a query string when the form is being sent by POST.
<input type="hidden" name="id" value="<?php echo $answerid; ?>" />
You're missing a closing quote here:
<form action='a_insert.php?id=" . $answerid . " method=post>
It should be:
<form action='a_insert.php?id=" . $answerid . "' method=post>
However you should be using code like this:
<table class="forum">
<tr>
<td class="forum"><b>Enter Response Here:</b></td>
</tr>
<form action="a_insert.php?id=<?php echo $answerid?>" method="post">
<tr class="forum">
<td class="forum"><textarea rows="5" cols="80" name="cBody"></textarea></td>
</tr>
<tr class="forum">
<td><input type="submit" value="submit"></td></tr>
</form></table><br><br>
精彩评论