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?
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, include or require 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.