我開始使用Windows記事本文件保存該人員的「feed」的社交網絡。但是,在我的帳戶保存頁面上,我的PHP似乎不起作用。它不會保存文件。很抱歉,如果我是「小白」f_open沒有創建文件?
這裏是我的代碼:
<?php
$u = $_POST['user'];
$n = $_POST['name'];
$p = $_POST['password'];
$e = $_POST['email'];
$f = $_POST['email'] . ".txt";
$con=mysqli_connect("localhost","root","password","account");
mysqli_query($con,"INSERT INTO socialnet (name,user,password,file,email) VALUES ($n,$u,$p,$f,$e)");
$o = fopen('/' . $f,'c');
fwrite($o,"Hi. I just joined. Wait a few until I get my feed going");
fclose($o);
echo "<b>Your account has been saved. Now, please click the link at the top of the page to go back and log in.</b>";
?>
請,沒有嚴厲的迴應。
您是否擁有目標文件夾內的寫入權限?您必須將文件夾權限設置爲777,並且有多種方式可以執行此操作,具體取決於您訪問該文件夾的方式。通過shell它是chmod 777 /文件夾名稱/ – Bernhard
是的。它是我自己的服務器 – Andy
請修復SQL注入漏洞!使用預準備的語句 – ComFreek