return to I Love My Journal
A Little Closer to Center...
Musings about Life, Linux, and Latter-day Saints.
Pages
About Me
Links


Tags
PERSONAL 512
SPIRITUAL 408
LDS 312
BOOK OF MORMON 237
SCRIPTURES 154
STUDIO-JOURNEY 122
RELIGION 112
LINUX 79
COMPUTERS 65
LIFE 60
GENERAL CONFERENCE 45
GENTOO 39
MISCELLANEOUS 37
MUSIC 37
PROGRAMMING 33
CARS 29
FAMILY 23
MICROSOFT 23
AUDIO 21
I LOVE MY JOURNAL 18
FUN 15
CHILDREN 12
CURRENT EVENTS 10
NATURE'S WAY 10
VIDEO 9
DRM 9
CONEXM 7
BABBLINGS 7
PROVO CITY CENTER TEMPLE 6
FRIENDS 6
HEROD THE FINK 5
COMPUTER HARDWARE 5
GAMES 5
DRUMS 4
HAND OF GOD 3
AUDIO HARDWARE 3
STUDIO 3
KDENLIVE 3
ADVERSITY 3
GENERAL INSANITY 3
THANKS4GIVING 2
CATS 2
CHURCH NOTES 1
FOREVERGREEN 1
POLITICS 1
POETRY 1
YOUTH CONFERENCE 1
GOSPEL 1
PARENTING 1
MY JOURNAL 1
EVERYDAY THOUGHTS 1


RSS Feed

RSS FeedSubscribe!
Thu - Sep 20, 2007 : 06:13 pm
content
   rated 0 times
>>next>>
<<previous<<
"Posting Forms to Sessions" - Trick
Any web developer who has been in the craft for more than a couple of days realizes how often forms are used in web development.  Well...  Where forms are used, form methods are used, and one of the crazily irritating problems with forms using a "POST" method is the fact that when the "back" button is pressed after leaving the initial posted page, a pop-up shows its nasty face and asks a question, to which most people don't know the answer.  Luckily, in my experience, most people just click "Ok".



So... What to do about this?  Are we all doomed to forever forget the awesome power of posting forms due to a silly quirk such as this!??!  I say unto you NO!!!

Steve Dibb, a good friend of mine, came up with a brilliant solution to this pesky  posting problem perpetuated by problematic programming!  What is this solution?

SESSIONS!

Yes...  The best way to deal with this problem is both simple and brilliant:

Simply catch the entire posted form held within the $_POST variable and assign it to a session ($_SESSION) variable.

After doing that, simply do a soft-redirect using the "header" command.

This solution assumes you're programming in PHP, although I'm quite certain it can be done in other languages as well.

Anyway... After doing that, BOOM!  Your posted information causing the pop-up warning to appear disappears into a nice safe session variable to be held as long as is necessary.

Something as simple as the following should do the trick quite nicely in most scenarios:

if(!empty($_POST)) {
    $_SESSION["posted_form"] = $_POST;
     header("Location:./");
}  

Or something similar.

Anyway... Kudos to Steve and thanks for sharing the knowledge!  It's worked fantastically for me since ya told me about it.