We help IT Professionals succeed at work.

Using header location ? trying to create a target.

andyJSP
andyJSP asked
on
My script is a basic message board. One file writes to the database and the other reads. Both these files load up in two different I-frames on the same page. My problem is when a user posts something I want it to refresh the I-frame with the PHP file that reads from the database so that they can see what they just posted.

Right now it?s an html file with the form utilities that submits its content the post.php file. The post.php has this at the end of the document to the HTML page with the form utility:
header ("Location: index.html");

But I also want it to reload list.php in frame ?content?.
I tried doing this but it didn?t work:
header ("Location: list.php Window-target: content");

Can you help me? (I?ll be check back a lot)

andy
Comment
Watch Question

Commented:
I guess you need to try javascript.
when your page finish processing the post you should have a javascript like

<script language="javascript">
window.frnamename.location.href = "list.php";
</script>

Author

Commented:
I was looking for more a php script.

Im raising the points to 300.

Author

Commented:
sorry,
I was looking for more of a php script.

Commented:
i ran into the same question. i did it with combine php and javascript. sorry, i know you want a pure php script, but it's not going to work.

you can refrsh both frame by add the javascript to the end of the post.php. header is not going to reload both frame, unless you write a client/server application.
do you have a url that I can take a look at it in progress at least.

Commented:
sure, it's in chinese though...

http://202.3.169.230/ocean/
hi!

well one way to go is if you make a frameset file -- something like index.php -- and then call the file with the file name you wish to open as a parameter.

Example:

header("Location: index.php?file=test.html");

you would write that at the end of your post.php file.

in index.php you would just change the src parameter of the frame to the parameter passed to index.php

example:

<frame name="content" src="<?= $file ?>">

and then index.php would load the desired file.

hope it helps

bostjan

Author

Commented:
Yes but that would require the entire page to reload of the src to change.

Commented:
If you wanted to do this strictly with PHP, you could reload your entire Frameset page.  If it was a PHP page itself, you could then pass variables to all of the enclosed pages at once.  For instance:

<framset>
     <frame name="left" src="left.php?a=1&b=2">
     <frame name="main" src="main.php?x=23&z=2">
</frameset>

A user would click a link that went to your frameset, loading it at the top level.

<a href="frameset.php?a=1&b=2&x=23&z=2" target="_top">

I hope this helps!

-Nate

Author

Commented:
Nothing with reloading the page. Only the iframe.

Commented:
Andy,
Using "Client PULL" technic in your source file of the second IFRAME.This technic needs to periodically refresh only your second iframe not entire page.
     
This is an example:

File: big_frame.html

<iframe src="frame_1.html" >
<iframe src="frame_2.php">

File: frame_2.php
<Head>
 <Meta HTTP-EQUIV="Refresh" CONTENT="5; frame_2.php">
</Head>
<?php
  // This file should be refreshed every 5 seconds.
  // Your PHP Code Start Here

?>


Kimcheng,
Your php has an error about exceeding execution time.
the statement,ini_set("max_execution_time", $seconds);, should help you. ( if you use PHP 4.0.0 or later )

Commented:
andyJSP,
  you can load both iframes with javascript from one of them if you gave the iframe names. or you can do what i did, change them from hidden frameset page still using javascript.

teuy,
thanks.
i did set the execution time to 600 secs with
  set_time_limit(600);
but it doesn't always work. i can't change the execution time for php to try to connect to DB

Commented:
kimcheng,
the set_time_limit function has no effect if your PHP is running in safe mode. ( safe_mode = On in php.ini)

Andy,
Sorry! I'm going out of your topic.

Author

Commented:
I'm just planing on using Javascript like was earlier mentioned.
Thank you everyone,
i'm exepting the first comment as the answer.

see ya,
andy

Author

Commented:
That javascript idea has worked out great for me, thank you.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.