I need to add couple of php page as from action like,
<form action=“one.php”, “two.php” method=“POST”> The code above is not working, how can i use more than one form action url?
HTML supports only one action on a <form>, but you can send the same form to different URLs by giving each submit button its own formaction. This works without JavaScript and is ideal when (as noted) different buttons should perform different server-side tasks.
<form action="/default.php" method="post">
<!-- form fields here -->
<button type="submit" name="do" value="one" formaction="/one.php">Save</button>
<button type="submit" name="do" value="two" formaction="/two.php" formmethod="post">Save & Notify</button>
</form> The browser will POST to the URL set on the clicked button, overriding the form’s action. You can also override method/target per button with formmethod/formtarget. See MDN: form element and MDN: button element.
For graceful fallback or if you prefer a single endpoint (as and recommend), post to one controller and branch based on which button was clicked:
$action = $_POST['do'] ?? 'one';
if ($action === 'two') {
// handle two.php logic
} else {
// handle one.php logic
} If your goal is to hit two URLs from one click (e.g., log + notify), avoid firing two independent browser requests, which can race or partially fail. Do the orchestration server-side in one request, so validation, database writes, and downstream calls happen atomically with proper error handling and retries. This keeps user experience consistent and prevents double-submits or mismatched states.
Jump to Post— Dani 5,664If your form includes two submit buttons that each need to do something different, you can use AJAX (Javascript on the front end) to override the form action based on which button is pressed.
Why do you have your form processing done in two separate files? What you have is invalid html, but you could use action="process.php", and then in the file process.php just include the two files you want to use: <?php include "one.php"; ?> and <?php include "two.php"; ?> if you really must do it that way.
As webmachine states send the form to one file and then send data onwards from there once everything has been validated and cleaned. If you need the data to perform a few procedures, you can do this via includes. For example...
//do validation on POST vars
if(!$validate) header('file0.php?err=1');
include 'file1.php';
include 'file2.php';
$success = file1func($var1) & file2func($var7) ;
$qs = ($success) ? 'msg=1' : 'err=2';
header('file0.php?'. $qs) ;
exit;If your form includes two submit buttons that each need to do something different, you can use AJAX (Javascript on the front end) to override the form action based on which button is pressed.
If you need both to be request from the browser, using POST, you can use AJAX.
<form onsubmit="handleSubmit()">
</form>
<script type="text/javascript">
function handleSubmit(e) {
e.preventDefault();
// then two ajax request
// may be you can use jQUery
}
</script> If you just need to execute both files, is your choice.
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.