我开始使用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