Jump to content

problem with small guestbook script


triaje

Recommended Posts

hey everybody I have a problem!!!

see i have a guestbook(a html file and a php file) that produces a txt file. the thing is i use this guestbook as a journal

and I call the txt content from a flash thats where my problem began.

 

this is the php file, my html form  call

<?php

$name = $_POST['Name']; 			
$comments = $_POST['Comments'];
$timedate = date("M d, Y (g:i a)", time() + 7200);

if ($name == "" or $comments == "") {
echo "One or more required fields were not completed. Please go back and try again. <br /><br />";
} else {
$oldinfo = file_get_contents("bookdata.txt");
$guestbookdata = fopen("bookdata.txt", "w+");
fwrite($guestbookdata, "$name  - $timedate \n");
fwrite($guestbookdata, "Comments: $comments \n \n");
fwrite($guestbookdata, "$oldinfo");
fclose($guestbookdata);
readfile("bookdata.txt");
}
?>

 

to get the flash  display the data.txt  I have to add a variable at the begining of the txt file

so I added a line at the php script that writes a "var=" at the beginnin of each entry but  then i found var= in each entry so is not quite neat.

 

<?php

$name = $_POST['Name']; 			
$comments = $_POST['Comments'];
$timedate = date("M d, Y (g:i a)", time() + 7200);

if ($name == "" or $comments == "") {
echo "One or more required fields were not completed. Please go back and try again. <br /><br />";
} else {
$oldinfo = file_get_contents("bookdata.txt");
$guestbookdata = fopen("bookdata.txt", "w+");
fwrite($guestbookdata, "Entry= ");
fwrite($guestbookdata, "$name  - $timedate \n");
fwrite($guestbookdata, "Comments: $comments \n \n");
fwrite($guestbookdata, "$oldinfo");
fclose($guestbookdata);
readfile("bookdata.txt");
}
?>

 

my question is how do i disapear the xml flash variables first before copying  the file(see script) so i dont get to see "Entry=" at the beginning of the each. i just needed at the begining of the file

 

apreciate help

 

 

Link to comment
https://forums.phpfreaks.com/topic/50935-problem-with-small-guestbook-script/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.