Target in php header refresh

Discuss coding issues, and scripts related to PHP and MySQL.
User avatar
JanMolendijk
Posts:282
Location:Holland Rotterdam

Target in php header refresh

Dear Admin sorry I post twice questions into few hours
but I try to add a target="shout" into this code what I did went all wrong
I realy hope you have a sugestion for me `thanks for your support`

Code: Select all

if($stmt->execute())
{
  $successMSG = "You succesfully Shouted...";
  header("refresh:5;Show-Shout-Reply.php?id=$users[id]&id_2=$_GET[notice_id]"); // redirects image view page after 5 seconds.
}
else
{
  $errMSG = "error while inserting....";
}
This is wrong but for example

Code: Select all

refresh:5;Show-Shout-Reply.php?id=$users[id]&id_2=$_GET[notice_id];target:shout

Admin Posts:805
Hello,
From what i know, there is no "target" option to the php header('refresh') function.
The correct sintax for header('refresh') is:

Code: Select all

header('Refresh:5; url=page_url.php');
echo 'Refresh in 5 seconds.';

If the target you want to refresh is an <iframe> you should rethink the code to use javascript.
For example, this code refreshes an <iframe to specified page-url after 5 seconds;

Code: Select all

<script>
window.setTimeout("refreshIFrame();", 5000);
function refreshIFrame() {
 document.getElementById('iframe_id').src='your_page_url.php';
}
</script>

JanMolendijk Posts:282
Thanks for the explain, stupid question why after 5 seconds refreshIFrame ?
is it a problem if I set this to 1 second ?

Admin Posts:805
You can put the time you want, in javascript the time is in miliseconds (1000 =1 second, 500 =0.5 seconds).