1
我正在爲我的大學課程開發一個項目,在這個項目中,我們必須將用戶名和密碼寫入文本文件。但是,無論何時我嘗試運行此操作,信息都不會寫入文檔中。任何建議將非常感激。PHP寫入文本文件
<?php
session_start();
$User = $_GET["user"];
$name = $_GET["name"];
$_SESSION["user"] = $User;
$_SESSION["name"] = $name;
$pass = rand(100000, 999999);
$file = fopen("accounts.txt", "w");
fwrite($file, $User);
fwrite($file, $pass);
fwrite($file, $name);
fclose($file);
$array = explode(" ", $name);
?>
<!DOCTYPE html>
<html>
<body>
<?php
$message = "Hello $name, you are registered. Your password is: $pass";
mail($User, "Homework Registration", $message);
print("All Done");
?>
</body>
</html>
我想通了。我沒有寫作權限。謝謝! –