Good Day Folks, seeking your assistance with a little issue.
The code presentation will be in three parts.
I have passed a value to a modal from a form using javascript. I want to use that value to run a query to populate the fields in the modal. I have placed the value to the modal in type=hidden and I have verified that the value is present in the modal. However in the when I try to use the value using $variableName = $_POST['valueName']; it throws this error: Warning : Undefined array key "regulation" in C:\xampp\htdocs\JCF_Portal\php\userEditModal.php on line 7 Line 7 is <?php echo $RegNum; ?>
How can I resolve this problem?
Here are the code snippets:
<td><form action='' method='POST'><div class='btn-group' role='group'><button type='button' class='btn btn-warning' data-bs-toggle="modal" data-bs-target="#userEdit" onclick="editUser()">EDIT</button><input type='button' class='btn btn-danger' name="passwordReset" value='RESET' /><button type='button' class='btn btn-danger' data-bs-toggle="modal" data-bs-target="#userDelete" onclick="editUser()">DELETE</button><input type='hidden' id="registration" name='regNumber' value="<?php echo $row["RegNumber"] ?>"/></div></form></td>
This one triggers the modal and runs the JS Function
function editUser()
{
document.getElementById('regulationNumber').value = document.getElementById('registration').value
}
JavaScript Function the pushes value to type=hidden on modal.
<div class="modal-header">
<input type="hidden" name="regulation" id="regulationNumber" value="">
<?php $RegNum = $_POST['regulation']; ?>
<h5 class="modal-title" id="exampleModalLabel">Edit User - <?php echo $RegNum; ?> </h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close></button>
</div>
These are they, could you tell me where I have gone wrong, please?