help me out please
Posted: Sat Jun 10, 2006 12:55 am
ok. This is what I'm (hopelessly) trying to do.
Diagram: http://i26.photobucket.com/albums/c135/ ... iagram.gif
This is what I have so far:
Page 1 - index.php
PHP Code:
Page 2 - insert.php
PHP Code:
And then I have 2 text files.
file.txt
and
file1.txt
Can you help me out please?
Diagram: http://i26.photobucket.com/albums/c135/ ... iagram.gif
This is what I have so far:
Page 1 - index.php
PHP Code:
Code: Select all
<?php
$myFile = "file1.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
echo $theData;
?>
<html>
<body>
<form action="insert.php" method="post">
First Name: <input type="text" name="first">
<br>
Enter Sentence: <input name="second" type="text" value="" size="50" maxlength="50" />
<br/>
<input type="Submit" value="Enter">
</form>
</body>
</html>PHP Code:
Code: Select all
<?php
$first - $_POST['first'];
$second = $_POST['second'];
?>
<html>
<body>
<?
$ffile = "file1.txt";
$fh = fopen($ffile, 'w');
fwrite($fh, $count);
fwrite($fh, "\n");
fwrite($fh,$first);
fwrite($fh,$second);
fclose($fh);
$myFile = "file.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh,1);
fclose($fh);
if ($theData == 0){
$count=1;
$ffile = "file.txt";
$fh = fopen($ffile, 'w');
fwrite($fh, $count);
fwrite($fh, "\n");
fwrite($fh,$first);
fwrite($fh,$second);
fclose($fh);
}
else{
$ffile = "file.txt";
$fh = fopen($ffile, 'a');
fwrite($fh, $count);
fwrite($fh, "\n");
fwrite($fh,$first);
fwrite($fh,$second);
fclose($fh);
}
$myFile = "file.txt";
$fh = fopen($myFile, 'r');
$theData = fread($fh, filesize($myFile));
fclose($fh);
?>
<br><hr>
<? echo $theData?>
<hr>
<form action="index.php">
<input type="Submit" title="back">
</form>
</body>
</html>And then I have 2 text files.
file.txt
and
file1.txt
Can you help me out please?