Shoutbox in PHP and Flash

u want the window to close after adding to the text file?

and also, is there a way to insert a variable name in front of the entire thing so I can load it into flash (ie Data=THEN WHAT IS ALREADY THERE) ?

yes, so that the only window open still is the flash movie


<?php
function closeit(){
?>
<SCRIPT language = "javascript">
	window.close();
</SCRIPT>
<?
}

$filename = "shoutbox.txt"; 
$fp = fopen($filename,"r");
$Data = fread($fp, 80000);
fclose( $fp ); 

//$DataArray = split (".:::.", $Data);

//Put in the starting tag and the ending tag number
//for ($n = 0; $n < 20; $n++) {
//print $DataArray[$n]; 
//}

print $Data;

closeit();
?>

Add this to shoutbox.php

add it at the end? like after the ?>

thanks, it works, but is there any way to get around the popup box that asks if you want to close the window?

Overwrite it

OK, thanks :smiley:

ure welcome :wink:

can it be saved in the text file though as Data=“THEN THE TEXT” ? and how can you disable the box asking if you really want to close it?

Yes it can be written like that. I dunno how to disable the box :frowning:

how do you write it like that though? oh, ok

or how about instead of making it open a new window, having it open in the same window and go back when it’s done?

or open it in a hidden frame, would that work?

hmm, it can b done. all u gotta do is change the “_blank” in the send(…) to the proper id

O.K. thanks, but can you answer one more question for me?

how can i change it from saying |NEW-MESSAGE|OLD-MESSAGES| to saying |“Data=”|NEW-MESSAGE|OLD-MESSAGES| ?

Thats what Ive been trying to figure out for a while. My knowledge about file handling in php is a bit rusty. I’ll see if i can come up with soomething

ok, thank you :smiley:

how about paying me :P. jk, finally i got it, here u go.


<?php

//if ($_POST['Submit']){
	$nameReceived = $_POST['Name'];
	$emailReceived = $_POST['Email'];
	$commentsReceived = $_POST['Comments'];

	$Name = ereg_replace("[^A-Za-z0-9<>]", "", $nameReceived); 
	$Email = ereg_replace("[^A-Za-z0-9 @.-/'<>]", "", $emailReceived); 
	$Comments = ereg_replace("[^A-Za-z0-9 @.-/'<>]", "", $commentsReceived);

	$Name = stripslashes($Name); 
	$Email = stripslashes($Email); 
	$Comments = stripslashes($Comments); 


	$filename = "shoutbox.txt"; 
	$fp = fopen( $filename,"r"); 
	$goto = fseek($fp, 5);
	$OldData = fread($fp, 80000); 
	fclose( $fp );
//	$Input = "<a href=\"mailto:$Email\"><b>$Name</b></a>: $Comments<br><br>.:::."; 
	$Input = "<a href=\"mailto:$Email\"><b>$Name</b></a>: $Comments<br><br>";
	$New = "$Input$OldData";
	$fp = fopen( $filename,"r+"); 
	$goto = fseek($fp, 5);
	fwrite($fp, $New, 80000); 
	fclose( $fp );
	header("Location: shoutbox.php"); 
//}


//else
//	print"Error";

?>

overwrite the add.php with the above.

Remember to do one thing though. In the shoutbox.txt, add data= in the beginning

thanks :smiley:

you really do deserve to be payed for all the work you have done, but I don’t really have a very big budget :frowning: lol

do you really want it to be rerouted to shoutbox.php from add.php? shoutbox.php has no use, all it does is display the contents of the file.