Click here to get back home

a la ViewState in PHP5?

 HomeNewsGroups | Search

comp.lang.php - PHP programming language discussions 

get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
a la ViewState in PHP5? Jivanmukta 05-22-2009
Posted by Jivanmukta on May 22, 2009, 2:14 pm
Please log in for more thread options
Hello,
I need your help in some programming problem. I have little experience
in web programming.
I have a page index.php (with announcements form). There is a button
opening page print.php (with printout of announcement) containing data
from $_POST (the data may not exist in database because printout can
be done before submit).
I would like such functionality: when user presses Back button, the
page index.php should appear with data previously entered.
I am not sure but it seems to me that in .NET there is ViewState
mechanism for such things. As far as I know ViewState is not
implemented in PHP.
Thus, this is how I imagine the solution:

print.php:
collects $_POST data in $_SESSION;
displays announcement printout using $_POST data

index.php:
fills in the announcement form using $_SESSION data, but if there's
no such data, empty form is displayed

Is it OK? Do you see better solution?

Posted by Jerry Stuckle on May 22, 2009, 2:55 pm
Please log in for more thread options
Jivanmukta wrote:
show/hide quoted text

You can't do it with PHP. Often the back button doesn't even result in
a request to the server - the browser just pulls the page from its cache.

For those few times when there is a request to the server, it's a simple
matter to test the $_SESSION array to see if the data exists and display
it. But it will be very unreliable.

Better is to use a browser (such as FireFox) which does remember the
data entered also, and displays it with the page when the back button is
pressed.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Posted by Jivanmukta on May 23, 2009, 4:25 am
Please log in for more thread options
show/hide quoted text
I don't know which browser the user will use.
BTW, I use Firefox and it does not display entered data when back
button is pressed.

How do you like another solution of my problem: to show
print_announcement.php in another window using window.open() function?

Posted by Jerry Stuckle on May 23, 2009, 6:46 am
Please log in for more thread options
Jivanmukta wrote:
show/hide quoted text

I'm not keen on unnecessarily opening additional windows, but you'll
need something client side to make the request to the host. If you
really need this, you should check a Javascript newsgroup.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================

Posted by Tim Roberts on May 25, 2009, 12:01 am
Please log in for more thread options
show/hide quoted text

Yes, it does, unless your page has metadata that disables caching.
--
Tim Roberts, timr@probo.com
Providenza & Boekelheide, Inc.

Similar ThreadsPosted
newbie: viewstate in PHP5? January 3, 2009, 2:45 am
PHP5 + IIS July 10, 2004, 12:27 am
XML-RPC and PHP5 September 17, 2004, 11:08 pm
PHP5 November 16, 2004, 4:05 am
php5 and xml January 4, 2005, 4:07 pm
Using OO in PHP5 January 14, 2005, 11:36 am
How to set $this in PHP5 February 5, 2005, 2:25 am
PHP5 as a CGI March 20, 2005, 5:08 am
Can I do this in php5? May 16, 2007, 1:28 pm
Re: Changes for PHP5 ? July 27, 2007, 4:23 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Driving a better car - Fuelzilla.com

Cabling site for homeowners and pros alike - Cabling-Design.com

Friends:

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap
Privacy Policy