Support Forums
Simple GuestBook - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Simple GuestBook (/showthread.php?tid=3846)



Simple GuestBook - nevets04 - 12-21-2009

This is my third project. Again for the sake of doing less work I uploaded it instead of pasting it.

Download:
http://www.mediafire.com/?yuntonjjnjz


RE: Simple GuestBook - Gaijin - 12-21-2009

Good job there man, that actually a simple script and I was amazed that it worked with only few lines.
Well done!

May I suggest you a change in your writting style.

Your script
PHP Code:
<?php
$message
=$_POST["message"];
$name=$_POST["fname"];
?>
<?php
$file
=fopen("mboard.txt","a");
fwrite($file,$name);
fwrite($file,": ");
fwrite($file,$message);
fwrite($file,"<br><br>");
fclose($file);
?>
<script type="text/javascript">
<!--
window.location = "http://nevets04.comoj.com/board.php"
//-->
</script> 

A bit better looking
PHP Code:
<?php
$message
=$_POST["message"];
$name=$_POST["fname"];

$file=fopen("mboard.txt","a");
fwrite($file,$name);
fwrite($file,": ");
fwrite($file,$message);
fwrite($file,"<br><br>");
fclose($file);

echo <<<HTML
<script type="text/javascript">
<!--
window.location = "http://nevets04.comoj.com/board.php"
//-->
</script>
HTML;

?>



RE: Simple GuestBook - nevets04 - 12-21-2009

Thanks, the only thing I'm worried about is once a lot of people post, loading time is going to really long.


RE: Simple GuestBook - Gaijin - 12-21-2009

Yeah that can become a real pain.
If you don't switch to MySql, you can create new file for every post and allow only limited amount of characters (255 - 500).
The you can limit the load by addin Pagination (it's pretty simple), and just load 5 posts per side...
If you also use more files and not just one, you can easy delete specified posts.

But I gone bit too far, are you planing to make this better or is it just a learning project?




RE: Simple GuestBook - nevets04 - 12-22-2009

(12-21-2009, 11:47 PM)Master of The Universe Wrote: Yeah that can become a real pain.
If you don't switch to MySql, you can create new file for every post and allow only limited amount of characters (255 - 500).
The you can limit the load by addin Pagination (it's pretty simple), and just load 5 posts per side...
If you also use more files and not just one, you can easy delete specified posts.

But I gone bit too far, are you planing to make this better or is it just a learning project?


More just a learning project, but I still appreciate the help if I ever need to use this (which I probably will)


RE: Simple GuestBook - Spl3en - 12-22-2009

Nice script Smile !

But, be careful !
When you display the messages, don't forget htmlentities !
You will be victim of XSS if you don't use that.

PS : You can concatenate string and variables like this, if you want :
PHP Code:
fwrite($file$name ": " $message "<br><br>"); 



RE: Simple GuestBook - nevets04 - 12-22-2009

(12-22-2009, 07:57 AM)Spl3en Wrote: Nice script Smile !

But, be careful !
When you display the messages, don't forget htmlentities !
You will be victim of XSS if you don't use that.

PS : You can concatenate string and variables like this, if you want :
PHP Code:
fwrite($file$name ": " $message "<br><br>"); 

Thanks, I was looking for ways to fix xss exploits


RE: Simple GuestBook - Socrates - 12-22-2009

Nice Nevets.