简体   繁体   中英

How to send the same data into multiple forms using php?

I'm writing a php file that can send the same form data to different urls on different servers.

<?php 
$urls = array("some_url_num1.php", "some_url_num2.php", "some_url_num3.php");
foreach ($urls as $url) {
echo '<form action="'.$url.'" method="post">
Time From: <br> <input type="text" name="timefrom"><br>
Time to: <br><input type="text" name="timeto"><br>
Password: <br> <input type="password" name="password"><br>
<input type="submit"><br></form>';
}
?>

Currently there are 3 forms on the page, and the user needs to enter the same data (timefrom, timeto, password) three times in order to get the result from some_url_num1.php, some_url_num2.php, some_url_num3.php.

Is there anyway, using php, to let the user enter only once, and get the result from the three .php files?

  1. Create a single form

  2. Collect data in a single php file

  3. From that php file, send user submitted data to other urls using curl

For CURL details you can refer PHP manual

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM