Forum Moderators: coopster

Message Too Old, No Replies

PHP/HTML and Refreshing Frames

         

ke4nyv

2:43 am on Mar 3, 2009 (gmt 0)

10+ Year Member



I am working on a VERY basic bulletin board that my family can use to post messages. So far, I have most of it working close to what I want. Here is what I have:

The main URL is just a plain old HTML document that creates two horizontal frames.

<snip>


<html>
<frameset rows="75%,25%">

<frame src="famtreebb.php">
<frame src="bbbot.htm">

</frameset>
</html>

The top frame is a simple PHP file. I used PHP so I could implode the message board posts that are stored in an HTML file. I am also using a table to "squeeze" the whole thing down. Here is the code:


<html>

<body>

<table align="center" width="75%" cellpadding="5" cellspacing="0" border="0">
<tr>
<th><h1><u>Rausch/Utlak Family Tree Bulletin Board<u></h1></th>
</tr>
</table>

<table align="center" width="75%" cellpadding="5" cellspacing="0" border="0">
<tr>
<tr>
<td>

<?

echo implode("",file("famtreebbmessages.htm"));

?>

</td>
</tr>
</table>
</body>
</html>

The bottom frame is an HTML file with basic forms. The button calls a simple PHP script that I put together with some code fragments I picked up and a little bit I came up with on my own.

The script simply takes the person's name and their message and writes them to the famtreebbmessages.htm file as an addition to an unordered list <ul>. When the top frame loads, the PHP script implodes this file and shows the current posts that have been written to this file by the bottom script.

Here is the script:


<html>
<body>

<?

$email = "jason@example.com";

$name = $_POST['name'];
$message = $_POST['message'];

//Send alert email
mail($email, "New Family Tree Message Posting", "You have a new posting to the Rausch/Utlak Message board!");

//Post message to board
$myFile = "famtreebbmessages.htm";
$fh = fopen($myFile, 'a+') or die("can't open file");
fwrite($fh, "<li><strong><font color='blue'>$name: </font></strong>$message</li>\r\n");
fclose($fh);

header("Location: http://www.example.com/bbbot.htm");

?>

</body>
</html>

You'll notice that the last line of the script just reloads the bottom frame so I get a clean form for the next post.

My problem is, I am looking for a way to refresh the top frame with the PHP script so the new posting shows in the top frame. I can post a test message and and then refresh the page and see what I just posted, but I am looking for a way to automate that.

I really could use some help with this last bit.

Thanks!
Jason.

[edited by: eelixduppy at 3:49 am (utc) on Mar. 3, 2009]
[edit reason] no URLs, please [/edit]

dreamcatcher

8:26 am on Mar 11, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi Jason, welcome to WebmasterWorld. :)

Have you had any luck with this. Is there any reason you need to use iframes?

dc

d40sithui

2:45 pm on Mar 11, 2009 (gmt 0)

10+ Year Member



I think one way to do this is to have the "bbbot.htm" page reload the "famtreebb.php" everytime it is refreshed. If you have an onLoad() function inside the main body of "bbbot.html" that targets the other frame, it may work. I haven't tested it, so you may have to play around with the code a bit.

//naming the frames


<html>
<frameset rows="75%,25%">

<frame src="famtreebb.php" name="famtree">
<frame src="bbbot.htm" name="bb">

</frameset>
</html>

<inside bbbot.html>


<body onLoad="top.frames['famtree'].location.reload();">

ke4nyv

6:40 pm on Mar 11, 2009 (gmt 0)

10+ Year Member



D40, that did it! Thanks!

I figured the best way to get the top frame to refrsh was a last command in the PHP script ran by the bottom frame, but I could'nt find anything that worked.

Your way was perfect and so simple!

Thanks again.