Moe Kayal
Moe Kayal

Reputation: 31

trying to identify which form submitted in php

I'm trying to make several forms in the same page and I have faced a problem that the php code is not responding for the submission action

    <form id="DeleteEmployeeModal" name="DeleteEmployeeModal" method="post">>
                <div class="modal-header">                      
                    <h4 class="modal-title">Delete Employee</h4>
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                </div>
                <div class="modal-body">            
                    <div class="form-group">
                        <label>Name</label>
                        <select  class="form-group" required>

            </select>
                    </div>

                </div>
                <div class="modal-footer">
                    <input type="button" class="btn btn-default" data-dismiss="modal" value="Cancel">

                </div>
                <input type="submit"  name="formAddEmplyee" class="btn btn-danger" value="Delete">
            </form>
<?php if(isset($_POST["DeleteEmployeeModal"])){

`echo "What is happpopoihsdafopishdfpoishdfpoaishdfpoiasdhfpoiashdfpoih";`}`?>`

Upvotes: 1

Views: 30

Answers (1)

Nick
Nick

Reputation: 147166

One way around this is to add a hidden form name input to each form:

<input type="hidden" name="formname" value="DeleteEmployeeModal" />

Then in your PHP you can just check the value of $_POST['formname'] to see which form was submitted.

Upvotes: 1

Related Questions