Guest Book

khansen's picture
This is the text we used for learning PHP. Copy this text and follow the directions I give you. Soon, I will actually write those directions her in the file.
<html>
<head>
<title>My Daily Log</title>
</head>
<body>
<table width=300 border=0>
<tr>
<td><strong><h4>This is my Daily Log</h4></strong></td>
</tr>
<tr><td>I&apost;ve given myself some room to add new entries.  All I have to do is type the new log entry in the box and hit submit.</td></tr>
<tr><td>
<?php
if(file_exists("daily_log.txt")){
        $file="daily_log.txt";
        $fh=fopen($file,"a+t");
//      echo "File Exists";
//      echo "........<br>";
        echo strip_tags($_POST['LogEntry']);
        $content=fread($fh,filesize($file));
        if(isset($_POST['LogEntry'])){
                echo $_POST['LogEntry'];
                fwrite($fh,$_POST['LogEntry']);
                fclose($fh);

        }else{
                fclose($fh);
        }
?>
<form name="New Log entry" action="" method="POST">
<textarea cols=45 rows=15 wrap=SOFT name="LogEntry"></textarea>
<br>
<input type="Submit" value="Submit" label="Submit">
</form>


<?
}else{

        echo "File does not exist";
}
?>
</td></tr>
<tr><td><?php echo $content; ?></td></tr>
</table>
</body>
</html>

Trackback URL for this post:

http://www.nuesdesk.org/trackback/98