Jump to content

[SOLVED] Submitting a form to same page that expects GET


jeff5656

Recommended Posts

When a user click this:

<a href="billing/editdos.php?action=edit&id=<?php
 echo $row['id_incr']; ?>">
  Billing</a>

 

They go to the page below called editdos.php.  I put a <form> with name dx1, on this that I want it to reload editdos.php.  The POSTed variable works, BUT the GET[id] info is lost so record doesn't get queried anymore. How do I correct this?  I think the answer lies in what I put in the hidden form variable, but then I don't know how to deal with case, and the GET (because the <a href link no longer applies).  Hope this isn't too confusing!

 

include "connectdb.php"; 

switch ($_GET['action']) {

case "edit":
$consultsq1 = "SELECT * FROM icu INNER JOIN dos ON icu.id_incr = dos.pt_id AND icu.id_incr = '" . $_GET['id'] . "' order by dos.billing_date"; 



$result = mysql_query ($consultsq1) or die ("Invalid query: " . mysql_error ());


for($n=0;$row = mysql_fetch_assoc ($result);$n++) {
   if(!$n){
      echo "<div align='center'><h3>Billing data for: " . $row['patient'] . " MRN: " . $row['mrn'] . "</h3></div>";
  echo "<u>ICU Admit Date</u>: " . date('m/d/Y', strtotime($row['rcf_date2'])); 
  echo "<table><tr><th>Date</th><th>Level</th><th>Diagnoses</th></tr>";
   }
   echo "<tr><td bgcolor='FFFFFF'>";
   ?><a href="editbill.php?action=edit&id=<?php echo $row['dos_id']; ?>"><?php echo date('m/d/Y', strtotime($row['billing_date'])); ?></a>
   <?php echo "</td><td bgcolor='FFFFFF'>" .  $row['billing_lvl'] . "</td><td bgcolor='FFFFFF'>";
   echo "<table ><td bgcolor='FFFFFF'>";?>

<form name="dx1" method="post" action="editdos.php"><input type="hidden" name ="dx1" value="<?php echo $row['dx1']; ?>"/>
    <input type="hidden" name ="dos_id" value="<?php echo $row['dos_id']; ?>"/>
<input type="hidden" name ="pt_id" value="<?php echo $row['pt_id']; ?>"/>
    <input type="submit" value="<?php echo $row['dx1']; ?>" />
    </form>

I think if I read this correctly that you need to put the id in the url again with the form, a quick example would be:

 

<form name="dx1" method="post" action="editdos.php?action=edit&id=<?php echo $id; ?>">

 

Of course when you start the page you would have to get the id. Hopefully that makes sense.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.