Guest Book
Posted: Mon Apr 09, 2007 5:26 am
Hi, i'm trying to make a simple guest book.
i already built the sign part now i want to build a function that allows the user to view the guest book.
this is what i have so far:
sign guest book:
view guest book:
well the view guest book doesn't work it prints some non sense like "dincmet eiSmtigEs"
what i want to do is just print every character exept \n or # (since these are gonna be my denoters).
also since we'r on the subject, how can i move the file ponter as i please?
thanks
i already built the sign part now i want to build a function that allows the user to view the guest book.
this is what i have so far:
sign guest book:
Code: Select all
<?php
if(!$_POST["userName"]=="" && !$_POST["body"]==""){
$entry = $_POST["userName"] ."#". $_POST["body"]."\n";
if(!$guestBook = fopen("guestBook.txt","a")){
echo "Error, could not open guest book.";
exit;
}
if(!fwrite($guestBook, $entry)){
echo "Error, unable to write on file.";
exit;
}
echo "Thank you for signing. <a href=viewBook.php>Click here</a> to view guest book";
fclose($guestBook);
}else echo "Invalid Name and/or Comment.";
?>Code: Select all
<?php
$guestBook=fopen("guestBook.txt","r");
if(!$guestBook){
echo "Error, could not read file";
exit;
}
while(!feof($guestBook)){
if(fgetc($guestBook) != "\n"){
echo fgetc($guestBook);
}
}
fclose($guestBook);
?>what i want to do is just print every character exept \n or # (since these are gonna be my denoters).
also since we'r on the subject, how can i move the file ponter as i please?
thanks