ok i made a simple text based tag board style thingy with smileys and it workes quite well but there is one major problem
lets get our heads rought what im trying to do shall we—
i have 5 files.
tags.txt where the php script’s outputs are stored and then read as html and displayed as the posts
board.php this is the user interface, it has a frame with a file displaying the posts. it also has the html form that sends of the data to the php script
post.php this is the one that i dont think is working right. it recieves the data from the form on board.php and runs htmlspecialchars and the smiley function i made using arrays and writes the output to the txt file
smileylist.php this has nothign to do with the actual proccess of the script it just shows the smileys and their commands in an html table
messages.php this file may not be nesesary atm but i added it when i was first trying out the smileys. but theres no harm in keeping it, it may have a slight problem though
ok ok enough babling on, heres the code in post.php
[code=php]
<?php
function smilies($text){
$smilies[‘plaintext’] = array(“:)”,”:(“,”:@”,”:o”,”:s”,”:|”);
$smilies[‘htmltext’] = array(“<img src=’smilies/smile.GIF’>”,”<img src=’smilies/unhappy.GIF’>”,”<img src=’smilies/angry.GIF’>”,”<img src=’smilies/shocked.GIF’>”,”<img src=’smilies/confused.GIF’>”,”<img src=’smilies/ok.GIF’>”);
$text = str_replace($smilies[‘plaintext’],$smilies[‘htmltext’],$text);
return $text;
}
$name = htmlspecialchars($_POST[‘name’]);
$messagesmiley = htmlspecialchars($_POST[‘message’]);
$message = smilies(“$messagesmiley”);
$tags = fopen(“tags.txt”, “r+”);
$post = “<tr><td colspan=2 bgcolor=green>Name: $name</td></tr><tr><td bgcolor=grey valign=top>Message:</td><td bgcolor=grey> $message<br><br></td></tr>”;
fwrite($tags, $post);
fclose($tags);
header(“location: board.php”);
?>
ok, the problem i have is that it writes over the previous posts, so it efeectivly truncates the file only r+ is specifically designed not to. im not sure why its not working. it only fwrites the post that the user entered
heres my other problem which may be on messages.php
it always outputs the new post and if it is smaller than the previous one then it has whats left of the old post stuck above it usually something like tr>. and its annoying. i think it is having the same affect as you get if you press insert and every new character overwrites the old one.
heres the link of the file board.php take a look at my problem
[URL=http://www.boz.trotinter.net/learning/message%20board/board.php]This is the board
feel free to test it
ty in advanced. i would like to get this workign so i can put it up on my site