各位朋友,我想实现把用户在表单里写的字符写入到某一个文件里面去,是怎么实现呢?如果我是写到linux系统的配置文件里面去的话,有没有涉及的权限的问题?请帮忙看看下面的代码有没有错,谢谢~
<?php
$fp = popen("wo.txt ", "r");
if(!$fp)
{
echo'文件不存在';
exit;
}
fwrite($fp, $_POST["ip"] .$_POST["network"] .$_POST["netmask"] ."\n");
pclose($fp);
print"修改成功!";
$ip=$_POST["ip"];
$network=$_POST["network"];
$netmask=$_POST["netmask"];
//$message = "<p><span style=\"color: green; background-color: transparent;\">密码成功!</span></p>";
?><form action="general_network.html" method="post">
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<td>IP地址:</td>
<td><input name="ip" type="text" /></td>
</tr>
<tr>
<td>子网掩码:</td>
<td><input name="network" type="text" /></td>
</tr>
<tr>
<td>设置网关:</td>
<td><input name="netmask" type="text" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" value="确 定" /> <input name="reset" type="reset" value="清 除" /></td>
</tr>
</table>
</form>
<?php
$fp = popen("wo.txt ", "r");
if(!$fp)
{
echo'文件不存在';
exit;
}
fwrite($fp, $_POST["ip"] .$_POST["network"] .$_POST["netmask"] ."\n");
pclose($fp);
print"修改成功!";
$ip=$_POST["ip"];
$network=$_POST["network"];
$netmask=$_POST["netmask"];
//$message = "<p><span style=\"color: green; background-color: transparent;\">密码成功!</span></p>";
?><form action="general_network.html" method="post">
<table cellpadding="10" cellspacing="0" border="0">
<tr>
<td>IP地址:</td>
<td><input name="ip" type="text" /></td>
</tr>
<tr>
<td>子网掩码:</td>
<td><input name="network" type="text" /></td>
</tr>
<tr>
<td>设置网关:</td>
<td><input name="netmask" type="text" /></td>
</tr>
<tr>
<td colspan="2" align="center"><input name="submit" type="submit" value="确 定" /> <input name="reset" type="reset" value="清 除" /></td>
</tr>
</table>
</form>
if (isset($_POST["submit"])) {
file_put_contents('a.txt', $_POST['ip'].$_POST['networdk'].$_POST['netmask'].'\n');
}
?>
<form action="" method="post">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="122"> IP地址: </td>
<td width="478"><input type="text" name="ip" id="ip" /></td>
</tr>
<tr>
<td> 子网掩码: </td>
<td><input type="text" name="network " id="network " /></td>
</tr>
<tr>
<td> 设置网关: </td>
<td><input type="text" name="netmask" id="netmask" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="提交" />
<input type="reset" name="button2" id="button2" value="重置" /></td>
</tr>
</table>
</form>
if (isset($_POST["submit"])) {
file_put_contents('a.txt', $_POST['ip'].$_POST['networdk'].$_POST['netmask'].'\n');
}
?><form action="" method="post">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="122"> IP地址: </td>
<td width="478"><input type="text" name="ip" id="ip" /></td>
</tr>
<tr>
<td> 子网掩码: </td>
<td><input type="text" name="network " id="network " /></td>
</tr>
<tr>
<td> 设置网关: </td>
<td><input type="text" name="netmask" id="netmask" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" name="submit" id="submit" value="提交" />
<input type="reset" name="button2" id="button2" value="重置" /></td>
</tr>
</table>
</form>