Hi
I have setup a script to sends information to a flat file which contains table settings too, each table information sent to the flat file are unique in the sence that all the tables will always contain different info. Another file get information from a flat file and shows it. Now i want to be able to search that flat file and show the results, the person would put a number or a name in the search field and it will take them to the table where that name or number is. I dont know if im making sence but below is the actual script, now just to let you know im new at this so please bare whith me.
Form to fill out
PHP Code:
<form action="testsend.php" method=post>
Name: <input maxlength="100" name="name" value="name" size="10">
<br><br>
Number: <input maxlength="100" name="num" value="number" size="10">
<br><br>
<input type="submit" value="Send">
</form>
testsend.php - sends info to file
PHP Code:
<?
$date = date("H:i, jS F");
echo $date;
echo "<br>";
if( $name == "name" )
{
echo "You did not enter a name. <br>Please go back and add your name!<br>";
exit;
}
if( $num == "number" )
{
echo "You did not enter a number. <br>Please go back and add your numb er!<br>";
exit;
}
else
{
$outputstring = "<tr><td bgcolor=\"silver\">\t" .$date. "</td></tr><tr><td>Full Name: \t".$name. "</td></tr><tr><td bgcolor=\"silver\">DOMAIN: \t".$num. "</td></tr>\n";
@ $fp = fopen("test.txt", "a");
flock($fp, 2);
fwrite($fp, $outputstring);
flock($fp, 3);
fclose($fp);
echo "<p>Results: <b>Information was sent</b>.</p>";
}
?>
testview.php - where i can view my flat file info
PHP Code:
<?
if (file_exists("test.txt"))
echo "test file output:";
else
echo "no info inside.";
@ $fp = fopen("test.txt", "r");
if (!$fp)
{
echo "<td><p><strong>No info here."
."Please try again later.</strong></p></td></table></body></html>";
exit;
}
while (!feof($fp))
{
$order= fgets($fp, 100);
echo $order;
}
echo "Filesize: ";
echo filesize("test.txt");
echo "bytes";
flock($fp, 1);
flock($fp, 3);
fclose($fp);
?>
any advice is welcome
