简体   繁体   English

将表单提交到php页面,并保留POST数据以重定向页面

[英]Submit form to php page and carry over POST data to redirect page

I have found some general info on this question but nothing seems to answer my exact question. 我已经找到了有关此问题的一些常规信息,但似乎没有任何答案可以回答我的确切问题。

I have a form on a .php page, that when submitted POST's the inputs to another php page, which sends the form inputs to my email and then redirects to another php page using (Location: page.php) 我在.php页面上有一个表单,当提交POST的输入到另一个php页面时,该表单会将表单输入发送到我的电子邮件,然后使用(Location:page.php)重定向到另一个php页面

so: form.php --> email.php (hidden) --redirect--> submitted.php 所以:form.php-> email.php(隐藏)--redirect-> Submitted.php

I would like to have an input from form.php be carried over to a hidden input box on submitted.php 我想将form.php的输入传递到Submitted.php上的隐藏输入框

I hope this makes sense, thanks in advance for your help! 我希望这是有道理的,在此先感谢您的帮助!

edit: 编辑:

on submitted.php I will have a single hidden form input. 在submitted.php上,我将有一个隐藏的表单输入。 I need the value of that input to be equal to one of the inputs from form.php. 我需要该输入的值等于form.php的输入之一。 I will then POST that input to another php page (not seen above) that will send it to my email. 然后,我会将输入的内容发布到另一个php页面(上面没有看到),该页面会将其发送到我的电子邮件中。

Simply, put your sending email code in your submitted.php code and using sessions prevent user from duplicating his input by pressing F5 or refreshing submitted.php as follows: 只需将发送电子邮件代码放入您的Submitted.php代码中,并使用会话来防止用户通过按F5或刷新Submitted.php来复制其输入,如下所示:

in form.php 在form.php中

session_start();
$_SESSION['submit'] = true;

in submited.php 在submited.php中

session_start();
if (isset($_SESSION['submit']) && $_SESSION['submit']){

/*
* do your code
*/
  $_SESSION['submit'] = false;
}
else{
  echo 'some error';
}

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

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