473,769 Members | 5,601 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reload (refresh) page within an if statement

Hi all,

Is there a simple way in php to reload a page coded within an if
statement.(see code below)
It's very important that the session stays intact.
The filename is RCStudent.php

*************** * A peace of code*********** *************** *
<?php
session_start() ;
?>

if($_POST['ST']!='')
{
$_SESSION['nScreen']=2'';
}
elseif ($_POST['AT']!='')
{
$_SESSION['nScreen']=0'';

*** RELOAD CODE HERE ***
}

*************** **** End code*********** *************** *****

T.i.a.

Regards,

Tino Wintershoven.
The Netherlands.
Nov 28 '06 #1
8 6828
"T. Wintershoven" <tw***********@ casema.nlwrote in message
news:ra******** *************** *******@casema. nl...
Hi all,

Is there a simple way in php to reload a page coded within an if
statement.(see code below)
It's very important that the session stays intact.
The filename is RCStudent.php

*************** * A peace of code*********** *************** *
<?php
session_start() ;
?>

if($_POST['ST']!='')
{
$_SESSION['nScreen']=2'';
}
elseif ($_POST['AT']!='')
{
$_SESSION['nScreen']=0'';

*** RELOAD CODE HERE ***
}

*************** **** End code*********** *************** *****
Do a header("Locatio n: this_page_with_ appropiate_para meter_passing") ; ?

Shelly
Nov 28 '06 #2
Hi Shelly,

Thanks for your reaction.

When i do a header(location ), i get an error message:
Warning: Cannot modify header information - headers already sent.

The header is allready sent on the second line ... session_start() ... (see
code)

Tino

"Shelly" <sh************ @asap-consult.comwrot e in message
news:9A******** ********@newsre ad4.news.pas.ea rthlink.net...
"T. Wintershoven" <tw***********@ casema.nlwrote in message
news:ra******** *************** *******@casema. nl...
Hi all,

Is there a simple way in php to reload a page coded within an if
statement.(see code below)
It's very important that the session stays intact.
The filename is RCStudent.php

*************** * A peace of code*********** *************** *
<?php
session_start() ;
?>

if($_POST['ST']!='')
{
$_SESSION['nScreen']=2'';
}
elseif ($_POST['AT']!='')
{
$_SESSION['nScreen']=0'';

*** RELOAD CODE HERE ***
}

*************** **** End code*********** *************** *****

Do a header("Locatio n: this_page_with_ appropiate_para meter_passing") ; ?

Shelly


Nov 28 '06 #3
Ric
Not sure exactly what kind of "reload" you are talking about?
I assume you mean the client's browser should reload at specific times:

PHP can't reload a site, the browser does a reload if instructed to,
therefore you need to tell the client's browser to reload the page, just
add:

<META HTTP-EQUIV=REFRESH CONTENT="10; URL=RCStudent.p hp">

to your html head. Here the page is reloaded every 10 seconds

PHP can redirect with header location like someone else just mentioned.
And a redirect works only if you haven't echoed any html before doing a:

header("Locatio n: ....);
T. Wintershoven schrieb:
Hi all,

Is there a simple way in php to reload a page coded within an if
statement.(see code below)
It's very important that the session stays intact.
The filename is RCStudent.php

*************** * A peace of code*********** *************** *
<?php
session_start() ;
?>

if($_POST['ST']!='')
{
$_SESSION['nScreen']=2'';
}
elseif ($_POST['AT']!='')
{
$_SESSION['nScreen']=0'';

*** RELOAD CODE HERE ***
}

*************** **** End code*********** *************** *****

T.i.a.

Regards,

Tino Wintershoven.
The Netherlands.

Nov 28 '06 #4
You can't send a Location header after sending cookies (which
session_start() does).

So you either need to find a way to reload without starting a session,
or you need to print a <metarefresh tag into the page to reload it...
T. Wintershoven schrieb:
Hi Shelly,

Thanks for your reaction.

When i do a header(location ), i get an error message:
Warning: Cannot modify header information - headers already sent.

The header is allready sent on the second line ... session_start() ... (see
code)

Tino

"Shelly" <sh************ @asap-consult.comwrot e in message
news:9A******** ********@newsre ad4.news.pas.ea rthlink.net...
>>"T. Wintershoven" <tw***********@ casema.nlwrote in message
news:ra****** *************** *********@casem a.nl...
>>>Hi all,

Is there a simple way in php to reload a page coded within an if
statement.(s ee code below)
It's very important that the session stays intact.
The filename is RCStudent.php

************ **** A peace of code*********** *************** *
<?php
session_start() ;
?>

if($_POST['ST']!='')
{
$_SESSION['nScreen']=2'';
}
elseif ($_POST['AT']!='')
{
$_SESSION['nScreen']=0'';

*** RELOAD CODE HERE ***
}

************ ******* End code*********** *************** *****

Do a header("Locatio n: this_page_with_ appropiate_para meter_passing") ; ?

Shelly



--
CB
Nov 28 '06 #5
Christoph Burschka wrote:
You can't send a Location header after sending cookies (which
session_start() does).

So you either need to find a way to reload without starting a session,
or you need to print a <metarefresh tag into the page to reload it...
Or you buffer the output by calling ob_start() at the start of the script.
:-)

Regards,
Erwin Moller
>

T. Wintershoven schrieb:
>Hi Shelly,

Thanks for your reaction.

When i do a header(location ), i get an error message:
Warning: Cannot modify header information - headers already sent.

The header is allready sent on the second line ... session_start() ...
(see code)

Tino

"Shelly" <sh************ @asap-consult.comwrot e in message
news:9A******* *********@newsr ead4.news.pas.e arthlink.net...
>>>"T. Wintershoven" <tw***********@ casema.nlwrote in message
news:ra***** *************** **********@case ma.nl...

Hi all,

Is there a simple way in php to reload a page coded within an if
statement.( see code below)
It's very important that the session stays intact.
The filename is RCStudent.php

*********** ***** A peace of code*********** *************** *
<?php
session_start() ;
?>

if($_POST['ST']!='')
{
$_SESSION['nScreen']=2'';
}
elseif ($_POST['AT']!='')
{
$_SESSION['nScreen']=0'';

*** RELOAD CODE HERE ***
}

*********** ******** End code*********** *************** *****

Do a header("Locatio n: this_page_with_ appropiate_para meter_passing") ; ?

Shelly




--
CB
Nov 28 '06 #6
ED

"Christoph Burschka" <ch************ ****@rwth-aachen.dewrote in message
news:4t******** *****@mid.dfnci s.de...
You can't send a Location header after sending cookies (which
session_start() does).

So you either need to find a way to reload without starting a session, or
you need to print a <metarefresh tag into the page to reload it...
Um, you sure about that?
The code below works fine here:

<?php
session_start() ;

if (! isset($_GET['refresh'])) {
setcookie('foo' ,'Bar');
$_SESSION['foo'] = 'Bar';
header('Locatio n:'.$_SERVER['PHP_SELF'].'?refresh=1');
} else {
echo 'page refreshed';
echo '<br />Session foo: '.$_SESSION['foo'];
echo '<br />Cookie foo: '.$_COOKIE['foo'];
}
?>

maybe the OP is outputting something (whitespace etc) prior to the
redirection?

cheers
ED
Nov 28 '06 #7
ED wrote:
"Christoph Burschka" <ch************ ****@rwth-aachen.dewrote in message
news:4t******** *****@mid.dfnci s.de...
>You can't send a Location header after sending cookies (which
session_start( ) does).

So you either need to find a way to reload without starting a session, or
you need to print a <metarefresh tag into the page to reload it...

Um, you sure about that?
The code below works fine here:
[...]
>

Then I remember it wrong...

Oh, right: What you can't send after a cookie is the HTTP response code - such
as "HTTP/1.1 303 See Other". The status code apparently has to be the first
header sent, while the Location header can follow after the cookies just fine.

I've never used a Location header without explicitly setting a 3xx response yet,
so that's the reason for the mix-up.

--
Christoph Burschka
Nov 28 '06 #8
You most definitely cannot use Header once you have output something to
the screen. I have had to battle that one a few times. It all depends
on where the php code is put in your page. If it has to be after
something is output (<bodytag) why not use JavaScript? If before
<bodyuse <meta>.

Christoph Burschka wrote:
ED wrote:
"Christoph Burschka" <ch************ ****@rwth-aachen.dewrote in message
news:4t******** *****@mid.dfnci s.de...
You can't send a Location header after sending cookies (which
session_start() does).

So you either need to find a way to reload without starting a session, or
you need to print a <metarefresh tag into the page to reload it...
Um, you sure about that?
The code below works fine here:
[...]


Then I remember it wrong...

Oh, right: What you can't send after a cookie is the HTTP response code - such
as "HTTP/1.1 303 See Other". The status code apparently has to be the first
header sent, while the Location header can follow after the cookies just fine.

I've never used a Location header without explicitly setting a 3xx response yet,
so that's the reason for the mix-up.

--
Christoph Burschka
Nov 29 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2128
by: eric rudolph | last post by:
I am writing a photo gallery and suppose 8 photos are displayed. When the user clicks on a button under the picture, I want it to add that picture name to a "favorites" list within the session data, but NOT leave the page the user is on. How could I do this? thanks
1
2894
by: Cooper | last post by:
Hello, is possible to disable the reload (or update, for ie) of the a web page? If yes, what i do? Otherwise if isn't possible, what i do for to set the default value of a form when a user do a reload of update of the web page? Thank you, Cooper.
19
31071
by: Darren | last post by:
I have a page that opens a popup window and within the window, some databse info is submitted and the window closes. It then refreshes the original window using window.opener.location.reload(). The problem is that after the reload, it brings you right to the top of the page. When I click 'refresh" on the original page, it brings me back to the original viewing position. Is there a way to duplicate this in from the popup window. Also,...
18
10145
by: Alan Z. Scharf | last post by:
1. I have a chain of six asynch callbacks initiated by a button, and want the page to refresh at the end of each callback to display A. Results of a SQLServer query showing cumulative running time, and B. A progress bar. 2. I have this working with a refresh timer: <META http-equiv="refresh" content="5">
7
1927
by: fh | last post by:
hello! I 've a found way to reload my page automatically every n seconde using this code Response.AppendHeader("Refresh", "4"); it works fine but I wish to do the same with only a part of my aspx page that will reload to the server all the rest of the page has to stay static if I use a web User control but it reload all the page?
6
25916
by: Rain | last post by:
Does anyone have an idea on how to programmatically force a page to reload(refresh)? Im developing a asp.net web application using C#.. any help would be nice... Thanks in advance!
2
12923
by: ericisjusteric | last post by:
I have a page with multiple iframes and need to have the user (ie6) be able to click a button to refresh any one of the iframes - but also to click another button at the top of the page to refresh all of them - from the server (this could be on page refresh also) as the purpose is to reset the iframe to the original content in case the user clicked on a link in that iframe and changed it, but also in case there were updates to the original page...
14
2109
by: =?Utf-8?B?UGF1bA==?= | last post by:
Hi I tried a google search but could not find anything. I am trying to cause one webpage to reload when a second web page is closed. The second webpage loads data into a session variable and when closed I need to reload the first page loading in the data from the session variable. Since I need to close the sescond form just setting the post back url to the first page on the close button from the second page is not quite what I am looking...
0
9587
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10045
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9993
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8870
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7406
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2815
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.