Sir I have these codes

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<head>
<style type="text/css">

.box{
    margin:0 auto;
    width:30%;
    border:2px solid #CCC;
    height:auto;
    padding:10px;
    margin-top:50px;
}

</style>
</head>
<?php
$my_continent="";
$my_country="";
$my_city="";
$my_zip="";

if(isset($_POST["submit"])){
$my_continent = $_POST['continent'];
$my_country = $_POST['country'];
$my_city = $_POST['city'];
$my_zip = $_POST['zip'];
}
?>

<body>
<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>

<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">
</form>
</div>
</body>
<html>

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

please

Hi,

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, networking, learning, and sharing knowledge.