how do you get a php page to refresh or reload?
start right from the top again?

thanks in advance from sunny clearwater fl.

To refresh or reload php page, you can use "Meta"
e.g
<META HTTP-EQUIV=Refresh CONTENT="3; URL=http://www.yoursite.com/yoururl.php">

It will refresh in every 3 seconds. You can change 3 to number you like.

Member Avatar for fatihpiristine

or without url

<META HTTP-EQUIV=Refresh CONTENT="3">

Cant you just do a javascript refresh?

I dont like every time the page refresh. I want the page will be reloaded only once. can u help me to do that?

try this

header("Cache-Control: no-cache");

everytime the page is requested, a fresh copy is loaded. Is this what u r lookin for?

I dont like every time the page refresh. I want the page will be reloaded only once. can u help me to do that?

I am using php to get an image from database. when I get an image, the image will be shown after hitting the refresh button. pls help me to solve this

That must be because ur browser has a cache copy of the page...
browsers use this mechanism to enhance the surfing speed...
add this on top of ur page-

header(“Pragma: no-cache”);
header(“cache-Control: no-cache, must-revalidate”); // HTTP/1.1
header(“Expires: Mon, 26 Jul 1997 05:00:00 GMT”); // Date in the past

This will instruct browser not to maintain the cache copy of this specific page.. and hopefully u wont need to hit refresh to display ur image...
Cheers!!

I am using php to get an image from database. when I get an image, the image will be shown after hitting the refresh button. pls help me to solve this

Still its not working. The above code shown in output window. can u give me the full code to insert and retrieve image from the database by using blob.

Still its not working. The above code shown in output window. can u give me the full code to insert and retrieve image from the database by using blob.

its getting displayed in browser !!! Are you sure u placed these lines inside <?php tag??
Why dont u post up the code u r using and i shall suggest what modifications are required..

Have messed this up b4
If the nocache code is getting displayed in the browser in the output window
Assuming the page displayed is "page.php"
page.php includes the line <img src="getImageFromDatabase.php" alt='database blob image'> or something similar
The nocache code previously listed should be inserted in the <head> of "page.php" not "getImageFromDatabase.php" else that code is output to the browser as well as (or instead of) the image
the nocache code should work

Have messed this up b4
If the nocache code is getting displayed in the browser in the output window
Assuming the page displayed is "page.php"
page.php includes the line <img src="getImageFromDatabase.php" alt='database blob image'> or something similar
The nocache code previously listed should be inserted in the <head> of "page.php" not "getImageFromDatabase.php" else that code is output to the browser as well as (or instead of) the image
the nocache code should work

hey almostbob,
correct me if m wrong but the header function is supposed to execute before displaying any output in the browser isnt it? then how are u supposed to place it inside head tag.
I believe it must go on the top of page which is used to display the image ie which outputs html for image display... watsay?
what you are trying to tell is the use of meta tag inside head which is also an option but doesnt works with IE. so the best way is to use http headers...

for me it is 3am
corrected text should read
The nocache code previously listed should be inserted in "page.php" not "getImageFromDatabase.php" else that code is output to the browser

I want to upload audio and video into the database.. Is it possible? If possible, then tell me how to do that?

To ensure an image is reloaded, send a unique URL.

eg:

<img src="image.php?random-number123" />

Where random_number123 can be generated by:

<?php

$random = microtime(true);

// eg

echo '<img src="image.php?'.$random.'" />';

?>

just use: <?php header("Location: #"); ?>

for example:

<?php

if (true) {

header("Location: #");

} else {
// nothing happens
}

?>

or, make a text link:

<a href="#">click this link</a>

"#" is often used to redirect people to the top of a page, but it will actually refresh the page as wel.

Greetings,

if(isset($_SESSION)){
//DO NOTHING
}
else{
$_SESSION=true;
header ("Location: yourpage.domain");
}

Hie guyz! Have you tried

header( 'refresh: 2; url=/location/' );

where

refresh - tells the page to refresh
,
2 - tells the page to refresh in 2sec
and
url=/location/ - is the location of the page being refreshed.

U will notice that itz the same as redirecting but just to the same page.


For redirecting:

header( 'url=/location/' );

Just press F5.

I dont like every time the page refresh. I want the page will be reloaded only once. can u help me to do that?

I use to use the php header function to refresh pages, but most of the times received
error messages.
So ever since, i'm using the next command:

<?php
// Refresh page
echo '<script> window.location=" '.$_SERVER['PHP_SELF'].' "; </script>';

?>

hi any 1 help me, how reload a tab contented with ajax in php,the problem is i submit a sginup it switch to home tab...


<html>
<head>
<style type="text/css">

p.thin_red_line { font-size: 20px; line-height: 15px; margin: 0px; color: #FF0000; }
</style>
<style type="text/css">

.pic
{

width:465px;
height:5px;
float:top;
}

.par
{

text-indent:210px;
}

}


pre {text-indent: 30px}

#tabmenu {
color: #000;

margin: 12px 0px 0px 0px;
padding: 0px;
z-index:1;

padding-left: 100px }
#tabmenu li {
display: inline;
overflow: hidden;
list-style-type: none;}

#tabmenu a, a.active {
color: #aaaaaa;
background: #295229;
font: normal 1em verdana, Arial, sans-serif;

padding: 2px 5px 0px 5px; margin: 0px;
text-decoration: none;
cursor:hand;
}
#tabmenu a.active {
background: #ffffff;

} #tabmenu a:hover {
color: #fff; background: #ADC09F;
}
#tabmenu a:visited {
color: #E8E9BE;
}
#tabmenu a.active:hover { background: #ffffff;
color: #DEDECF;
} #content {font: 0.9em/1.3em verdana, sans-serif; text-align: justify; background: #ffffff; padding: 20px; border-top: none; z-index: 2; }
#content a {
text-decoration: none;
color: #E8E9BE;
}
#content a:hover { background: #aaaaaa; }
</style>

<script src="js/jquery-1.2.3.pack.js"></script>
<script language="JavaScript" type="text/javascript">
function callAHAH(url, pageElement, callMessage, errorMessage)
{
document.getElementById(pageElement).innerHTML = callMessage;
try
{
req = new XMLHttpRequest();
/* e.g. Firefox */
}
catch(e)
{
try
{
req = new ActiveXObject("Msxml2.XMLHTTP");
/* some versions IE */
}
catch (e)
{
try
{
req = new ActiveXObject("Microsoft.XMLHTTP");
/* some versions IE */
}
catch (E)
{
req = false;
}
}
}
req.onreadystatechange
= function(){responseAHAH(pageElement, errorMessage);};
req.open("GET",url,true);
req.send(null);
}
function responseAHAH(pageElement, errorMessage)
{
if(req.readyState == 4)
{
if(req.status == 200)
{output = req.responseText;
document.getElementById(pageElement).innerHTML = output;
}
else
{
document.getElementById(pageElement).innerHTML = errorMessage+"\n"+responseText;
}
}
}
</script>

<script language="JavaScript" type="text/javascript">
function reloadCaptcha(imageName)
{
var randomnumber=Math.floor(Math.random()*1001); // generate a random number to add to image url to prevent caching
document.images[imageName].src = document.images[imageName].src + '&amp;rand=' + randomnumber; // change image src to the same url but with the random number on the end

}
</script>
<script language="JavaScript" type="text/javascript">
function makeactive(tab)
{
document.getElementById("tab1").className = "";
document.getElementById("tab2").className = "";
document.getElementById("tab3").className = "";
document.getElementById("tab4").className = "";
document.getElementById("tab5").className = "";
document.getElementById("tab"+tab).className = "active";

callAHAH('content.php?content= '+tab, 'content', 'getting content for tab'+tab+'. Wait...', 'Error'); }
</script>

<script language="JavaScript" type="text/javascript">
function callDE()
{

document.getElementById ('MainDiv').style.display='';
document.getElementById ('MainDiv').style.visibility='visible';
document.getElementById ('MainDiv').style.position='absolute';

document.getElementById ('MainDiv').style.top='0px';
document.getElementById ('MainDiv').style.left='0px';
document.getElementById ('MainDiv').style.width= '100%';
document.getElementById ('MainDiv').style.height= '100%';

document.getElementById('MainDiv').style.backgroundColor = "Gray";
document.getElementById('MainDiv').style.filter = "alpha(opacity=60)";
document.getElementById('MainDiv').style.opacity = "0.6";


popupWindow = window.open("login.php","","location=no,directories=no,status=no,menubar=no,scrollb ars=no,resizable=no,width=400,height=200,left=350,top=200,Minimize=no");

window.opener.document.body.disabled=true;

document.getElementById ('MainDiv').style.display='none';
document.getElementById ('MainDiv').style.visibility='hidden';

document.getElementById ('MainDiv').style.top='0px';
document.getElementById ('MainDiv').style.left='0px';
document.getElementById ('MainDiv').style.width= '0px';
document.getElementById ('MainDiv').style.height= '0px';
}

</script>

</head>
<body onload="makeactive(1)">
<form id="frmMain" runat="server">
<div id="MainDiv"></div>
<table>

<tr>
<td align=right>
<div class=pic>
<h1 style="background-color:white"><image src="images\karthi.gif" alt="sponcered"></image>
</h1>
</div>
</td>
<td>
<table >
<tr align=left>

<td>
<a href="javascript:callDE()"><div class=par> member login </div></a>
</td>
</tr>
<tr align=left>
<td><P><div class=par>Sales Toll-Free (877) 360-3683</div></p></td>
</tr>
<tr align=left>
<td>

<ul id="tabmenu" > <li onclick="makeactive(1)"><a class="" id="tab1">home</a>
</li> <li onclick="makeactive(2)"><a class="" id="tab2">Sgin up</a></li>
<li onclick="makeactive(3)"><a class="" id="tab3">FAQS</a></li>
<li onclick="makeactive(4)"><a class="" id="tab4">Our Blogs</a></li>
<li onclick="makeactive(5)"><a class="" id="tab5">Contact us</a></li>
</ul>
</td>


</tr>
</table>
</td>


</tr>
</table>
</td>
</tr>
</table>
<hr></hr>
<div id="content"></div>


</body>

</html>

content page:

<html>
<head>

</head>
<body>
<?php
if ($_GET == 1)
{
include("home.php");
}
if ($_GET == 2)
{
include("captchaform.php");
}
if($_GET == 3)
{ echo 'Content For Page 3';
}
if ($_GET == 4)
{
echo 'Content for Page 4';
}
if($_GET == 5)
{
include("tutorial.html");
}
?>
</body>
</html>

If you meant to refresh the page once actions have been done (ie, the php page received instructions through URL/POST, then performed some changes such as table refresh/db content changes) and you wish to display the new status then you can use the php 'header' instruction (w/ full URL to the php page) to call the same page. Let's say your php code is in 'myphp.php', your domain is 'my.domain.site' and your php file is located at the 'cgi-bin' directory (or as configured in your web server), then the instruction will be as such:
header("location://my.domain.site/cgi-bin/myphp.php")
Make sure to 'unset' any GET/POST values as needed prior to refresh the page.

on top of your code:

ob_start();
$url = "location_of_file.php";
header ("Location : $url");

tanx guys i had the same problem,ur suggestionz have bin of help to me. (uzor frm nigeria)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.