以相同的格式将表单数据发送到两页php [英] send form data to two pages php in same format
问题描述
我需要将表单数据发送到两个不同的页面(a0.php& a1.php)
。我无法使用会话,因为我没有访问(a1.php)
页面。
所以现在我想要一些中间页面,我可以访问表单数据并将其重定向到另一页面作为表单发布。
现有
//前端
< form action =a1.phpmethod =post >
< / form>
// a1.php
<?php
var_dump($ _ POST);
?>
需要
//前端
< form action =a0.phpmethod =post>
< / form>
// a0.php
<?php
var_dump($ _ POST); //在这里访问表单数据
header(location:a1.php)//通过重定向传递表单数据
?>
// a1.php
<?php
var_dump($ _ POST); //在这里也以相同的格式/时尚访问表单数据
?>
注意:我不想在url中传递参数,在这种情况下,我更喜欢 POST
over GET
你可以使用javascript。
$ b $ on $ $ $ c $ onClick 将会发送数据到第一页而不刷新的函数(ajax) ,然后发送到第二页。
< form>
< button type = submitonclick =x()>
< / form>
< script>
function x(){
// ajax至a1.php
//发送至a2.php
}
< / script>
I need form data to be sent to two different pages(a0.php & a1.php)
. I cant use session because I dont have access to (a1.php)
page.
So now i want some intermediate page where i can access the form data and redirect to another page as form post itself.
existing
//front end
<form action="a1.php" method="post">
</form>
//a1.php
<?php
var_dump($_POST);
?>
Needed
//front end
<form action="a0.php" method="post">
</form>
//a0.php
<?php
var_dump($_POST); //access form data here
header("location:a1.php")// pass form post data through redirection
?>
//a1.php
<?php
var_dump($_POST); //access form data here also in same format/fashion
?>
Note: I dont want to pass parameters in url, in this case, I prefer POST
over GET
You can use javascript.
onClick
will fire function that will send the data to first page without refreshing (ajax), and so send to the second page.
<form>
<button type=submit" onclick="x()" >
</form>
<script>
function x(){
//ajax to a1.php
//send to a2.php
}
</script>
这篇关于以相同的格式将表单数据发送到两页php的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!