简体   繁体   English

将表单发布到其他页面然后返回

[英]post form to different page then return

My form on the-form-page.php gets POST'd on submit to handlerpage.php . 我在the-form-page.php的表单在提交到handlerpage.php时得到POST

After the POST I need to redirect back to the-form-page.php . POST之后,我需要重定向回the-form-page.php

Well that is absolutely no problem and is currently working. 好吧,那绝对没有问题,目前正在运行。 User fills out the form on the-form-page.php , presses 'submit', POST data is handled by handlerpage.php (some calculations and writing results to mysql database), then I successfully redirect back to the-form-page.php using window.location= 用户在-form-page.php上填写表格,按“提交”,POST数据由handlerpage.php处理(一些计算并将结果写入mysql数据库),然后我成功地重定向回了-form -page。使用window.location的php =

The problem is there is large data created on handlerpage.php from data submitted in the POST of the-form-page.php that needs to come back to the-form-page.php AND the original form data needs to come back to the-form-page.php also so the user sees 'Ah, there's my original data and there's the results.' 问题是,有从外形page.php文件 ,需要回来的外形page.php文件和原始表单数据的POST提交的数据上handlerpage.php创建大数据需要回来了-form-page.php,因此用户会看到“啊,有我的原始数据,有结果。”

I can't use GET to programmatically return to the-form-page.php -- data too big for GET params. 我无法使用GET以编程方式返回到form-page.php -数据对于GET参数而言太大。 And I'd like to stick with window.location= as the redirection method (if possible). 我想坚持使用window.location =作为重定向方法(如果可能)。

How can I redirect back to the-form-page.php and display the user's original data with the results of the processing from handlerpage.php ? 如何重定向回the-form-page.php并显示来自处理程序page.php的处理结果的用户原始数据?

NOTE: re-architecting so that the-form-page.php and handlerpage.php are combined is NOT an option. 注意:重新架构以使-form-page.phphandlerpage.php合并不是一个选择。

And I'm already partway there, after processing the data on handlerpage.php I'm successfully returning now to the-form-page.php , I just need to re-populate it with the original data and the new data created on handlerpage.php . 在处理完handlerpage.php上的数据之后,我已经到了那里,现在我成功地返回到form-page.php ,我只需要用原始数据和在handlerpage上创建的新数据重新填充它即可。 .php

How about PHP Sessions ? PHP会话怎么样? Here is a simple example . 这是一个简单的例子 In your the-form-page.php check session varible's value and populate. 在您的the-form-page.php中,检查会话变量的值并填充。 You can set sesions variables in handlerpage.php . 您可以在handlerpage.php中设置sesions变量。

It seems that you're trying to invent your own AJAX , only without A (and also JA and X ) in it. 似乎您正在尝试发明自己的AJAX ,只是其中没有A (以及JAX )。

I'd suggest you to submit form using AJAX, to return JSON-encoded "new data" on handlerpage.php and then to display the received content back on the-form-page.php . 我建议您使用AJAX提交表单,在handlerpage.php上返回JSON编码的“新数据”,然后在the-form-page.php上显示接收到的内容。

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

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