我知道这个问题是重复的,但是StackOverFlow和其他网站的所有问题都没有帮助我...所以我想在.txt
文件中保存输入中的用户名和密码,但我拥有的一切尝试到目前为止没有工作。这是PHP代码:
<?php
if(isset($_POST['Submit-Button']))
{
$username = $_POST['Username'];
$password = $_POST['Password'];
$text = $username . "," . $password . "\n";
$fp = fopen('accounts.txt', 'a+');
if(fwrite($fp, $text)) {
echo 'Saved';
}
fclose ($fp);
header("Location: http://www.google.com");
die();
}?>
这是我的HTML:
<span>Username</span>
<input type="text" name="Username" id="Login-Input-Username">
<span>Password</span>
<input type="password" name="Password" id="Login-Input-Password">
<button type="submit" name="Submit-Button" value="submit" id="Login-
Button">Sign In</button>
因此,点击登录后,accounts.txt
文件为空,我无法理解为什么它无效。