简体   繁体   English

是否有可能发送多个表单到PHP自我发布

[英]is it possible to send multiple forms to php self with post

我只能通过GET实现这一点,如何通过POST重新提交不同的表单时,如果没有丢失以前的数据,我会提交多个表单吗?

Use hidden input fields? 使用隐藏的输入字段?

<input type="hidden" />

Store in a session? 存储在会话中?

session_start();
$_SESSION['blarr'] = $_POST['old-data'];

将以前的表单数据保留到数据库或会话中。

Take your previous data in session array. 在会话数组中获取以前的数据。

Or you can post your data again using hidden fields in your form. 或者,您可以使用表单中的隐藏字段再次发布数据。

This code should loop through all POST and insert them into a hidden input field. 此代码应循环遍历所有POST并将它们插入到隐藏的输入字段中。 Put it inside the <form> tags, and it should be submitted with the subsequent post. 把它放在<form>标签内,它应该随后发布。

Remember to properly escape the output. 记住要正确地逃避输出。

foreach($_POST as $name => $value){
    echo '<input type="hidden" name="'.$name.'" value="'.$value.'" />';
}

Or you can save away the data in the manner you choose. 或者您可以按照您选择的方式保存数据。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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