Jump to content
Larry Ullman's Book Forums

Recommended Posts

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

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

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

  • 4 weeks later...

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

 Share

×
×
  • Create New...