简体   繁体   中英

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. Put it inside the <form> tags, and it should be submitted with the subsequent post.

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.

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