Post info after a refresh

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
JosiaMFire22
Forum Newbie
Posts: 9
Joined: Thu Oct 12, 2006 1:12 am

Post info after a refresh

Post by JosiaMFire22 »

ok pretty much Iv written a script like so

Define General Content (fixed)
Define variable Content
Refresh Page using header function (note this is also variable)

The problem I am faceing is that my script displays the variable content, but hence there is often a possible refresh, when there is a refresh, the variable content is lost. Note I want this variable content to be displayed Once and only once, just after the refresh.

The reason for the refresh is that the general content will often include a table from mysql, that needs to be refreshed as, later on in the script a new row is added.

I have tried a few different things, though my script often ends up in a loop, so the variable data ends up in a list form. I have spent some time, I am relativly new to scripting, so any help would be much apreciated

Thanks, Any questions as to what I mean, feel free
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

We can't refresh, sorry to say. We can only redirect which means that the particular page's information is lost, considering you are technically at a new page.

What you'll need to do is have the table updated before you begin to output. All back-end operations should be done prior to rendering. At no point should a redirect to the same page be necessary.
User avatar
califdon
Jack of Zircons
Posts: 4484
Joined: Thu Nov 09, 2006 8:30 pm
Location: California, USA

Post by califdon »

superdezign wrote:We can't refresh, sorry to say. We can only redirect which means that the particular page's information is lost, considering you are technically at a new page.

What you'll need to do is have the table updated before you begin to output. All back-end operations should be done prior to rendering. At no point should a redirect to the same page be necessary.
I would modify that a little. It's quite common to redirect to the same page with different parameters in either $_POST or $_GET variables. If you need to save data from one page to the next, you have two choices: either use $_SESSION variables or pass them as $_POST variables within a form (they can be hidden, if that's desirable) or as $_GET variables (to be avoided, if they contain hints about the content that you don't want to be obvious).

The other possibility is to use Ajax, which does enable you to refresh some data on a page without redirecting the whole page.
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

califdon wrote:It's quite common to redirect to the same page with different parameters in either $_POST or $_GET variables.
I didn't know that we could post custom data. :D :D How?
Post Reply