HTML提交表单代码:
<form name="form2" method="get" action="index.php" id="form2" onSubmit="return confirm('确认要操作?');"> <table width="100%" border="0" align="center" cellpadding="3" cellspacing="1"> <tr class="header"> <td height="25" colspan="2">配置修改 </td> </tr> <tr bgcolor="#FFFFFF"> <td height="25"><div align="right">姓名:</div></td> <td height="25"><input name="name" type="text" id="name" value="<?=$fr[name]?>" size="80"></td> </tr> <tr bgcolor="#FFFFFF"> <td height="25"><div align="right">住址:</div></td> <td height="25"><input name="cid" type="text" id="cid" value="<?=$fr2[cid]?>" size="80"></td> </tr> <tr bgcolor="#FFFFFF"> <td height="25"> </td> <td height="25"><input type="submit" name="Submit" value="设置"> <input type="reset" name="Submit2" value="重置"></td> </tr> </table> </form>
php修改文件内容代码:
<?php $name=$_GET['name']; $cid=$_GET['cid']; $newdata = <<<php <?php $name = '{$name}'; $cid = '{$cid}'; php; file_put_contents("config.php",$newdata); ?>
config.php内容:
<?php $name = '张三'; $cid = '武汉';