One form with two submit buttons and different actions for each button

Refer this :

Multiple submit buttons php different actions

Put this script in your page :

<script>
    function submitForm(action)
    {
        document.getElementById('columnarForm').action = action;
        document.getElementById('columnarForm').submit();
    }
</script>

Modify your input code :

<input type="image" name="camper" onclick="submitForm('formindb_hoh_1.php')" value="camper" src="../images/apps/camperBtn.png" class="submit_button" />
<input type="image" name="medical" onclick="submitForm('formindb_hoh_2.php')" value="medical" src="../images/apps/medicalBtn.png"class="submit_button" />

No JS, use HTML5.

Change the submit buttons to use new HMTL5 button attribute formaction:

<button type="submit" name="camper" formaction="formindb_hoh_1.php">Camper</button>
<button type="submit" name="camper" formaction="formindb_hoh_2.php">Medical</button>

Reference: http://devdocs.io/html/element/button


Finally, I got my answer after spending more than an hour. I tried a various method like switch case, jquery, and JavaScript. But I only used HTML5 formaction tag and now my form two submit button working at two location.

Code :

   <input type="submit" class="btn btn-success" value="Pay Now" name="submit"  style="width: 100%; letter-spacing: 1px; color: #fff; border: none;padding:  10px;" formaction="example.php">

   <button type="submit" class="btn btn-success" name="submit" style="width: 100%; letter-spacing: 1px; color: #fff; border: none;padding: 10px; margin-top: 15px;" formaction="mail.php"> Button</buttton>

Tags:

Php

Forms