Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在php文件之间传递用户输入?_Php_Html - Fatal编程技术网

如何在php文件之间传递用户输入?

如何在php文件之间传递用户输入?,php,html,Php,Html,现在我有了一个简单的电子邮件登录表单 <form action="one.php"> <input type="email" name="email"/> </form> one.php是对gmail用户进行电子邮件过滤,并将他们发送到自定义路径 <?php $email = $_POST['email']; if (stripos($email, '@gmail.com') !== false) { header('Location:

现在我有了一个简单的电子邮件登录表单

<form action="one.php">
<input type="email" name="email"/>
</form>

one.php是对gmail用户进行电子邮件过滤,并将他们发送到自定义路径

<?php

$email = $_POST['email'];

if (stripos($email, '@gmail.com') !== false) {
    header('Location: ../gmail/index.html');
} else {
 header('Location: /unknownusers');
}
?>

现在我们完成了第一页 我的问题是 如何通过电子邮件将名称发送到/gmailusers中的其他页面示例

<html>
<head>
</head>
<body>
<div> 
<font>Welcome back,</font>
<?php
include 'one.php'; 
  echo $email; ?>  
</div>
</body></html>

欢迎回来,,
$email在此模式下不起作用,因为one.php没有保存的信息

我怎样才能做到这一点

欢迎回到'用户。Email@gmail.com"

index.html文件中


任何人都可以帮我写php代码。

你所做的没有意义,但是为了让它工作,在
two.php
replace

echo $email;

但是您正在
one.php
中重新加载页面,因此不应执行上面的代码更改。(你为什么这样做?)无论如何,如果安全性不是问题,在
one.php
中,你可以通过这样做将电子邮件传递到其他页面

header('Location: ../gmail/index.html&email='.$_POST['email']);
然后,在
index.html
文件中,访问变量
$\u GET['email']


如果安全性是一个问题,这会变得更复杂。

最简单的方法是不使用
位置
重定向,而只包括要显示的文件

one.php
您可以使用会话存储变量,并在任何其他文件中使用它们。不客气。如果您发现某个问题很有用,请对其进行投票或单击复选标记将其作为正确答案接受。当我添加&id=给我请求的URL未找到时添加
?id=
用于分离变量。顺便说一句,感谢您的帮助,但我使用了file put&get和worket betterOK,但写入磁盘的速度比以任何其他方式传递数据慢1000秒。您可能有一个方便的解决方案,但速度非常慢。
header('Location: ../gmail/index.html&email='.$_POST['email']);
<?php

$email = $_POST['email'];

if (stripos($email, '@gmail.com') !== false) {
    include "gmail.php";
} else {
    header('Location: /unknownusers');
}
<html>
<head>
</head>
<body>
<div> 
<font>Welcome back, <?php echo $email; ?></font>
</div>
</body></html>