PHP把文本文档的内容按行输出来以后,如何按下图的形式显示出来

WBOY
Release: 2016-06-13 12:26:43
Original
924 people have browsed it

PHP把文本文档的内容按行输出来以后,怎么按下图的形式显示出来。


<br /><?php<br />//写入文本<br />$myfile = fopen("newfile.txt", "a+") or die("Unable to open file!");<br />$username=@$_POST[username];<br />fwrite($myfile, $username);<br /><br />$password=@$_POST[password]."<br>";<br />fwrite($myfile, $password);<br /><br />//读取文件<br />$myfile = fopen("newfile.txt", "r") or die("Unable to open file!");<br />// 输出单行直到 end-of-file<br />while(!feof($myfile)) {<br />  echo fgets($myfile) . "<br>";<br />}<br />fclose($myfile);<br />?><br />
Copy after login

<br /><html><br /><header><br /></header><br /><body><br /><form action="index.php" method="post"><br />用户名:<input type="text" name="username"/><br><br><br />密码:<input type="text" name="password" /><br><br><br /><input type="submit" value="提交"/><br /></form><br /><table border="0"><br /><tr><td>用户名</td><td>密码</td></tr><br /><tr> <br /><td><?php echo $username ?></td><br /><td><?php echo $password ?></td><br /><td>删除</td><br /></tr><br /></table><br /></body><br /></html><br />
Copy after login

------解决思路----------------------
form.php
<br /><html><br /><head><br />    <meta charset="utf-8"/><br />    <title></title><br /></head><br /><body><br /><form name="form" action="form-action.php" method="post"><br />    <input name="username" type="text" /><br />    <input name="password" type="text"/><br />    <input type="submit" name="submit" value="提交"/><br /></form><br /><?php<br />$path = 'D:\wamp\www\a.txt';<br />$f = fopen($path, "r");<br />echo "用户名"." " ."密码"." 操作<br/>";<br />while(!feof($f))<br />{<br />    if (!feof($f)){<br />        $buffer = fgets($f, 4096);<br />        $arr = explode("<br><font color='#FF8000'>------解决思路----------------------</font><br>",$buffer);<br />        if(count($arr) > 1){<br />            echo $arr[0]." " . $arr[1]." 删除<br/>";<br />        }<br />    }<br />}<br />fclose($f);<br />?><br /></body><br /></html><br />
Copy after login


form-action.php
<br /><?php<br />$username = $_POST['username'];<br />$password = $_POST['password'];<br />$path = 'D:\wamp\www\a.txt';<br />$fp = fopen($path,"a");<br />fwrite($fp,$username."<br><font color='#FF8000'>------解决思路----------------------</font><br>".$password."\r\n");<br />fclose($fp);<br />header("Location:form.php");<br />?><br /><br />用户名 密码 操作<br />11 22 删除<br />33 44 删除<br />55 66 删除<br />ss dd 删除<br />s sss 删除<br />
Copy after login

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!