sandari Posted March 5, 2013 Share Posted March 5, 2013 I give up!! What is wrong with this code? while($row = mysqli_fetch_array($result,MYSQLI_ASSOC)){ echo "<tr class=\"data\" align=\"center\" width=\"100%\"> <form action=\"edit_other_medical_problem.php\" method=\"POST\"> <td align=\"center\">{$row['AssessmentDate']}</td> <td align=\"center\">{$row['MedicalProblem']}</td> <td align=\"center\">{$row['TreatmentPlan']}</td> <td align=\"center\">{$row['OtherDetails']}</td> <td align=\"center\"> <input type=\"submit\" name=\"submit\" value=\"Edit\"> <input type=\"hidden\" name=\"MedicalProblemID\" value=\"{$row['ID']}\"> </td> </form>"; echo "<form action=\"delete_other_medical_problem.php\" method=\"POST\"> <td align=\"center\"> <input type=\"submit\" name=\"submit\" value=\"Delete\"> <input type=\"hidden\" name=\"MedicalProblemID\" value=\"{$row['ID']}\"> </td> </form>"; echo "</tr>"; } The "Delete" button works beautifully but the "Edit" button remains on this page instead of opening "edit_other_medical_problem.php". I cannot see the difference. Link to comment Share on other sites More sharing options...
HartleySan Posted March 5, 2013 Share Posted March 5, 2013 Hmmm... at first glance, it looks okay. Do you get any errors or anything, or does absolutely nothing happen when you click the button? Could you please provide a sample of the HTML that is created by this PHP? Thanks. Link to comment Share on other sites More sharing options...
margaux Posted March 5, 2013 Share Posted March 5, 2013 The second form action is overwriting the first. You need to give the forms different names. Link to comment Share on other sites More sharing options...
HartleySan Posted March 5, 2013 Share Posted March 5, 2013 Are you sure about that, margaux? I'm not saying you're wrong, but that seems weird. I created the following quick scripts to test things out, and both forms seem to submit fine: index.php <?php echo '<form action="form1.php" method="post"> <input type="hidden" name="a" value="a"> <input type="submit" name="submit" value="Submit"> </form> <form action="form2.php" method="post"> <input type="hidden" name="b" value="b"> <input type="submit" name="submit" value="Submit"> </form>'; Link to comment Share on other sites More sharing options...
HartleySan Posted March 5, 2013 Share Posted March 5, 2013 And the code for form1.php and form2.php is the same. The code is the following: form1.php/form2.php <?php print_r($_POST); By placing the three above files in the same folder and running index.php, both forms seem to properly submit to the intended scripts. Am I missing something? Edit: I had to make two posts, because for whatever reason, my post kept getting cut off if I only did one. Link to comment Share on other sites More sharing options...
margaux Posted March 5, 2013 Share Posted March 5, 2013 Big apologies, I read this far too quickly (and too early) on the train and was thinking this was two submit buttons. Code originally posted looks okay. Link to comment Share on other sites More sharing options...
HartleySan Posted March 5, 2013 Share Posted March 5, 2013 No problem. I've done that many times before too, margaux. Anyway, I guess we'll just wait for sandari to comment further before we jump to conclusions. Link to comment Share on other sites More sharing options...
margaux Posted March 5, 2013 Share Posted March 5, 2013 Thanks HartleySan. I've experienced his scenario myself but as you said we need more info to be able to debug. Link to comment Share on other sites More sharing options...
sandari Posted March 30, 2013 Author Share Posted March 30, 2013 Thanks for your input on this problem. It turned out that I had an error in the code where it had to decide whether Submitted was true or not. The program thought that Submitted was TRUE and just saved the variables back to the database and returned to the calling page. Thanks again. Link to comment Share on other sites More sharing options...
Recommended Posts