jquery - Issue while inserting data from modal - PHP
one text
I hope everyone is doing well here.
So, Basically, I was working on a modal for my portal, and the conflicting thing is that. Whenever I - Someone tries to fill and Submit the form together. It just sends a single person's data - Into MySQL.
What I have already tried.
- Insert a dummy data click to open the modal and Update on the submit button - Delete on the Cancel button.
The problem I'm facing while using the upper mentioned idea. The query deletes all the dummy values. I can't find a way to delete the data with the same id or something.
This query is for getting the max receipt no. and Putting that value on the input field to show on the modal form - That this is the receipt no. You're filling.
$query = "select MAX(Receipt_no) from payments";
$result = mysqli_query($conn,$query);
$row = mysqli_fetch_assoc($result);
$receipt_no = $row['MAX(Receipt_no)']+1;
$inputterr = $_SESSION['name'];
The second query is creating dummyvalue/ Slot for the users who will take fees. I did this to prevent duplicate entries at the same time.
$query_ru = "insert into payments(id,amount,remarks,receipt_no,full_name,fee_head,payment_mode,timings,inputter,amount_in_words,Month_Of_Payment,cheque_no,ef_no,FEE_TYPE)
values(Null,000000,'dummyvalue','$receipt_no','Fee in Process.','dummyvalue','dummyvalue','dummyvalue','$inputterr','dummyvalue','','dummyvalue','dummyvalue','Fee in process.')";
$exec_tu = mysqli_query($conn,$query_ru);
The below query will update the data of that slot which is made on click to the modal.
$x_id = $_GET['id'] ?? '';
$ef_no = $_POST['ef_no'];
$receipt_no1 = $_POST['receipt_no'];
$name = $_POST['name'];
$remarks = $_POST['remarks'];
$date = $_POST['date'];
$fee_head = $_POST['fee_head'];
$cheque_no = $_POST['cheque_no'];
$payment_mode = $_POST['payment_mode'];
$timings = $_POST['timings'];
$amount = $_POST['amount'];
$FEE_TYPE = $_POST['FEE_TYPE'];
$inputter = $_POST['inputter'];
$amount_in_words = $_POST['amount_in_words'];
$receiving_date11 = $_POST['date'];
$rec_date = date("d-M-Y",strtotime($receiving_date11));
$month_of_payment = $_POST['month_of_payment'];
$mop = date('y-m-d',strtotime($month_of_payment));
$query_t = "update payments set amount='$amount',ef_no='$ef_no',remarks='$remarks',FULL_NAME='$name',FEE_HEAD='$fee_head',PAYMENT_MODE='$payment_mode',AMOUNT_IN_WORDS='$amount_in_words',Month_Of_Payment='$mop',CHEQUE_NO='$cheque_no',TIMINGS='$timings',INPUTTER='$inputter',FEE_TYPE='$FEE_TYPE' where id='$x_id'";
$exec_t = mysqli_query($conn,$query_t);
The same thing is happening on the Cancel button that deletes the row data created when the modal is opened.
<div class="col-lg-6">
<br>
<input type="submit" value="Submit" class="btn btn-primary" name="BtnSave">
<!-- <button class="2 btn btn-danger" name="CancelBtn">Cancel</button> -->
<?php
// echo "<a href='deleteDummy.php?id=$hidden_id' class='2 btn btn-danger'>Cancel</a>";
echo "<a href='deleteDummy.php?id=$hidden_id'><button type='button' class='btn btn-danger' >Cancel</button></a>";
?>
</div>
Problem(2) I blocked refresh on that form as If someone refreshes that form, It doesn't not deletes from the table and Stays remains forever.
Well, I'm looking forward to someone's help. I would appreciate that!
I appreciate any help you can provide. Best, Taha
Source