chrisrog
Member
- Messages
- 33
- Reaction score
- 0
- Points
- 6
Just wondering about this since I'm using a file write and read setup in php for the comment box but also I've never been good at displaying things on web pages or at least setting up a good display.
Here's the 3 files that make this thing run.
The part of my PHPCommentsForum.php file that is the comment box. Yes it started out as a html file and was converted to a php one to let php work freely in it.
Here's my Save and Load files.
and the css file that holds any relevance to this directly
Just looking for ideas right now since it is working but I know it could probally be better.
Here's the 3 files that make this thing run.
The part of my PHPCommentsForum.php file that is the comment box. Yes it started out as a html file and was converted to a php one to let php work freely in it.
Code:
<div id="content">
<h3>Site Info</h3>
<div name="commentDisplayer" id="commentDisplayer" >
<h3>Comments Section</h3>
<p>This is meant for where the comments are going to show up but isn't setup fully yet so this message will be here until it is working.</p>
<?php include('LoadForumComments.php') ?>
</div>
<form name="commentsForm" id="commentsForm" action="SaveComments.php" method="post">
<fieldset>
<label id="usertag" for="user" >User Namer <input name="user" id="user" type="text" value="Guest" /></label>
<br />
<label id="commenttag" for="comment">Comment</label>
<br />
<textarea name="comment" id="comment" rows="5" cols="35">Replace this with your own text!</textarea>
<br />
<input type="submit" value="Submit"/>
</fieldset>
</form>
</div>
Here's my Save and Load files.
Code:
LoadForumComments.php
<?php
$file = "SavedForumComments.txt"; //Path to your *.txt file $_SERVER['DOCUMENT_ROOT'] .
$contents = file($file);
$string = implode($contents);
echo $string;
?>
SaveComments.php
<?php
$username = $_POST['user'];
$userComment = $_POST['comment'];
$file = "SavedForumComments.txt";
$openFile = fopen($file,"a") or die("Can't open file!");
fwrite($openFile, "\n" . '<div name="FileComment" class="FileComment">' . '<h2>' . $username . '</h2>' . '<p>' . $userComment . '</p>' . '</div>' . "\n");
fclose($openFile) or die("Can't close file!");
header("Location: PHPCommentsForum.php");
exit;
?>
and the css file that holds any relevance to this directly
Code:
form#commentsForm{
width: 40%;
background-color: gray;
float: left;
}
div#commentDisplayer{
width: 58%;
background-color: gray;
float: right;
margin: 3px;
}
div.FileComment{
border: groove 3px blue;
background-color: rgb(30,100,50);
margin: 20px;
}
div.FileComment code{
display: block;
}
Just looking for ideas right now since it is working but I know it could probally be better.