<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
<meta http-equiv= "Content-type" content= "text/html; charset=gb2312 "/>
<title>gwbjx123</title>
<link rel= "stylesheet" style type= "Text/css" href= "Style/basic.css"/>
<body>
<form action= "eg1.php" method= "POST" >
<table cellspacing= "2" cellpadding= "0" border= "0" >
<tr>
<th width= "bgcolor=" "Red" >Item</th>
<th width= "$" bgcolor= "Red" >Quantity</th>
</tr>
<tr>
<TD width= "" bgcolor= "green" >Tires</td>
<td><input type= "text" name= "Tires" size= "5"/></td>
</tr>
<tr>
<TD width= "" bgcolor= "green" >oil</td>
<td><input type= "text" name= "Oil" size= "5"/></td>
</tr>
<tr>
<TD width= "bgcolor=" "Green" >spark plugs</td>
<td><input type= "text" Name= "Spark" size= "5"/></td>
</tr>
<tr>
<TD width= "" bgcolor= "green" >Address</td>
<td><input type= "text" name= "Address" size= "/></td>"
</tr>
<tr>
<TD colspan= "2" align= "center" ><input type= "Submit" value= "Submit"/></td>
</tr>
</table>
</form>
</body>
Here is the PHP file: eg1.php
<?php
$tires = $_post[' tires ');
$oil = $_post[' oil '];
$spark = $_post[' spark ');
$address = $_post[' address '];
$outputstring = $tires. " \ t ". $oil." \ t ". $spark." \ t "
. $address. " \ n ";
echo "File stored in ......<br/>";
$fp = fopen ("Egtext.txt", "AB");//a is an additional
Flock ($FP, LOCK_EX);
if ($fp) {
Fwrite ($fp, $outputstring, strlen ($outputstring));
}
Flock ($FP, lock_un);
Fclose ($FP);
echo "file is stored. "
?>
<body>
<?
$fp = fopen ("Egtext.txt", "RB");
Flock ($FP, LOCK_EX);
while (!feof ($fp)) {
$order = fgets ($fp, 999);
echo $order. " <br/> ";
}
Flock ($FP, lock_un);
Fclose ($FP);
?>
</body>
<?
$orders = File ("Egtext.txt");//file files are loaded into a text file with 1 elements (records) per action in the file.
$count _orders = count ($orders);//Statistics total number of records.
if ($count _orders==0) {
echo "<p> No orders pending</p>";
}
echo "<table border=\" 1\ ">";
echo "<tr><th bgcolor=\" #ccccff \ ">Tires</th>
<th bgcolor=\ "#ccccff \" >oil</th>
<th bgcolor=\ "#ccccff \" >spark</th>
<th bgcolor=\ "#ccccff \" >address</th>
</tr> ";
for ($i =0; $i < $count _orders; $i + +) {
$line = explode ("\ t", $orders [$i]);//\t double quotation marks must be double quotes. Otherwise the data shows an error
$line [0]=intval ($line [0]); Probably because "\ t" is split in code when adding data
$line [1]=intval ($line [1]);
$line [2]=intval ($line [2]);
echo "<tr><td align=\" right\ ">". $line [0]. " </td>
<TD align=\ "right\" > ". $line [1]." </td>
<TD align=\ "right\" > ". $line [2]." </td>
<TD align=\ "right\" > ". $line [3]." </td>
</tr> ";
}
echo "</table>";
?>