title: Overwrite MySQL Values through HTML Form
body: <p>I have a rental system for apartments that I wrote and I have the rent amount and late fees coming from a database. Admins can renew the rent through a back end. What I want is for the renewal form to pull in the rent amounts and late fees from the database so I have the form fields set up in text box input fields. There are times when we would like to waive the late fee that the system automatically puts in, or give them a discount so the fee amount and the total need to be able to change. Here is how I have the input fields set up in the form:</p>
  
  <pre><code>&lt;input type="text" name="lateFees" id="lateFees" value="&lt;?=CURRENCY.$lateFees?&gt;" /&gt;
  &lt;input type="text" name="rent" id="rent" value="&lt;?=CURRENCY.$rentAmount?&gt;" /&gt;
  </code></pre>
  
  <p>This part works perfectly fine. I'm getting text fields that are prepopulated with the values from MySQL. The problem is if you replace those values the new amount isn't being transferred to the database. It keeps the original rent amount/late fee regardless of what you write in the text field. Here is my form action just so you can see what the form is actually doing. </p>
  
  <pre><code>&lt;form name="microForm" id="microForm" method="post" action="&lt;?=$_SERVER['PHP_SELF']?&gt;" enctype="multipart/form-data"&gt;
  </code></pre>
  
  <p>Here is the PHP that is being executed after the form is submitted:</p>
  
  <pre><code>$query-&gt;execute("INSERT INTO transaction SET admin_id='".$_SESSION['LogedInAdminId']."',user_id='".$booking-&gt;getUserId()."',booking_id='".$booking-&gt;getBookingId()."',rent_amount='".$rentAmount."',late_fees='".$lateFees."',payment_type='".$_REQUEST['paymenttype']."',notes='".addslashes($_REQUEST['notes'])."'");
  $txnId = $query-&gt;getLastInsertId();
  
  $sql = $query-&gt;execute("SELECT U.* FROM units U INNER JOIN booking_details B ON U.unit_id = B.unit_id WHERE B.booking_id='".$booking-&gt;getBookingId()."'");
  while($row=mysqli_fetch_assoc($sql))
  {
      $query-&gt;execute("INSERT INTO transaction_details SET txn_id='".$txnId."',user_id='".$booking-&gt;getUserId()."',unit_id='".$row['unit_id']."',for_months='".$_REQUEST['months']."',rent_amount='".$rentAmount."',late_fees='".$lateFees."'");
  }
  
  $query-&gt;execute("UPDATE booking SET renew_date = DATE_ADD(renew_date, INTERVAL ".$_REQUEST['months']." MONTH) WHERE booking_id='".$booking-&gt;getBookingId()."'");
  $booking = $blBooking-&gt;getById($_REQUEST['bookingid']);
  $errMsg = '&lt;span class="successtxt"&gt;Booking has been renewed';
  </code></pre>