Sir I have these codes

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">

<style type="text/css">

    margin:0 auto;
    border:2px solid #CCC;


$my_continent = $_POST['continent'];
$my_country = $_POST['country'];
$my_city = $_POST['city'];
$my_zip = $_POST['zip'];

<div class="box">
<form name="form1" action="<?php $_PHP_SELF;?>" method="post">
Continet:   <input type="text" name="continent" value="<?php echo $my_continent;?>"/><br />
Country:    <input type="text" name="country" value="<?php echo $my_country;?>"/><br />

<form name="form2" action="<?php $_PHP_SELF;?>" method="post">
City:   <input type="text" name="city" value="<?php echo $my_city;?>"/><br />
Zip:    <input type="text" name="zip" value="<?php echo $my_zip;?>"/><br />

<input type ="submit" name="submit" value="submit">

Is it possible to submit these two forms with single submit button. For some reasons I want to use two forms instead of one.


Recommended Answers

All 2 Replies


you cannot do this with plain HTML. You need javascript: you could use AJAX to submit the two forms, but you are going to generate two separated requests, with two separated responses from the server(s). Which means the second could return before the first is completed. Or one could fail, due to timeout or other issues. To solve these scenarios you could use the Promise API:

In practice the requests are performed asynchronously, and each will generate a promise, i.e. an object that represents a successful response or a failure. This can be done also in server side, see:

Can you explain why you want to keep them separated?

commented: Promises, promises :) These multiple-form submits never add up for me. +15

is it possible two forms two different actions using single submit button

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.