Dirty Form Error Trapping?
Dirty Form Error Trapping?
am 22.10.2007 18:45:31 von Fester Bestertester
Greetings,
I'm an occasional php/mysql dabbler.
I have a basic data form with a submit button. Unfortunately, it's still
possible for the user to enter data changes and close the window,
without clicking the submit button, thus losing the data.
Can someone point me to a generic example of some code that will trap
and handle this error?
Re: Dirty Form Error Trapping?
am 22.10.2007 19:39:21 von McKirahan
"Fester Bestertester" wrote in message
news:ffik1p$n5g$1@gondor.sdsu.edu...
> Greetings,
>
> I'm an occasional php/mysql dabbler.
>
> I have a basic data form with a submit button. Unfortunately, it's still
> possible for the user to enter data changes and close the window,
> without clicking the submit button, thus losing the data.
>
> Can someone point me to a generic example of some code that will trap
> and handle this error?
How is the user's choice of closing the window an error?
Is a "Close Window" button next to the "Submit Form" button?
Re: Dirty Form Error Trapping?
am 22.10.2007 20:14:51 von Jerry Stuckle
Fester Bestertester wrote:
> Greetings,
>
> I'm an occasional php/mysql dabbler.
>
> I have a basic data form with a submit button. Unfortunately, it's still
> possible for the user to enter data changes and close the window,
> without clicking the submit button, thus losing the data.
>
> Can someone point me to a generic example of some code that will trap
> and handle this error?
>
Nope. There is nothing you can do in PHP (which is server side) to
prevent the user from performing client-side functions such as closing a
window.
But that also should not be considered an error. It should be
considered normal operation, and your script should handle it nicely.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Dirty Form Error Trapping?
am 22.10.2007 20:51:07 von Fester Bestertester
McKirahan wrote:
> How is the user's choice of closing the window an error?
>
> Is a "Close Window" button next to the "Submit Form" button?
Thanks for replying. There is no Close Window button. I think it's just
a matter of making it clear to the users that this web db app works like
any other, i.e., if you go to your bank's web site, log on, and set up a
transaction to transfer some funds, but you don't click the "Commit"
button and instead just close the window, your transaction is not
completed. That shouldn't be too hard to handle.
Re: Dirty Form Error Trapping?
am 22.10.2007 20:55:41 von Fester Bestertester
Jerry Stuckle wrote:
> Nope. There is nothing you can do in PHP (which is server side) to
> prevent the user from performing client-side functions such as closing a
> window.
>
> But that also should not be considered an error. It should be
> considered normal operation, and your script should handle it nicely.
Thanks for responding. As I stated in my other response, I suppose it's
like any other web app. If the user clicks the browser's 'x' button
before clicking the submit button, the changes are lost. That's the way
our hr web/db app works.
But, as you state, "...your script should handle it nicely." I'm not
sure, how would this work exactly? Would it plant a cookie and show the
user a message?
Re: Dirty Form Error Trapping?
am 22.10.2007 21:48:21 von Courtney
Fester Bestertester wrote:
> Greetings,
>
> I'm an occasional php/mysql dabbler.
>
> I have a basic data form with a submit button. Unfortunately, it's still
> possible for the user to enter data changes and close the window,
> without clicking the submit button, thus losing the data.
>
> Can someone point me to a generic example of some code that will trap
> and handle this error?
Only way is via javascript.
Something like "onunload submit".
But the syntax is far more complex.
Another way to achieve what you want is to use javascript to submit the
form any time anything changes using teh onchange function.
Re: Dirty Form Error Trapping?
am 22.10.2007 22:11:14 von Jerry Stuckle
Fester Bestertester wrote:
> Jerry Stuckle wrote:
>
>> Nope. There is nothing you can do in PHP (which is server side) to
>> prevent the user from performing client-side functions such as closing
>> a window.
>>
>> But that also should not be considered an error. It should be
>> considered normal operation, and your script should handle it nicely.
>
> Thanks for responding. As I stated in my other response, I suppose it's
> like any other web app. If the user clicks the browser's 'x' button
> before clicking the submit button, the changes are lost. That's the way
> our hr web/db app works.
>
> But, as you state, "...your script should handle it nicely." I'm not
> sure, how would this work exactly? Would it plant a cookie and show the
> user a message?
>
>
Well, for instance, don't put in 1/2 an update when they click the first
window, then expect to finish the update when they click on the second
window. Wait until all the data is present, then insert it.
And don't laugh - I've seen this done before!
And like you said - just let them know if they don't finish, the data
will not be updated.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Dirty Form Error Trapping?
am 22.10.2007 22:13:10 von Jerry Stuckle
The Natural Philosopher wrote:
> Fester Bestertester wrote:
>> Greetings,
>>
>> I'm an occasional php/mysql dabbler.
>>
>> I have a basic data form with a submit button. Unfortunately, it's
>> still possible for the user to enter data changes and close the
>> window, without clicking the submit button, thus losing the data.
>>
>> Can someone point me to a generic example of some code that will trap
>> and handle this error?
> Only way is via javascript.
>
> Something like "onunload submit".
>
> But the syntax is far more complex.
>
> Another way to achieve what you want is to use javascript to submit the
> form any time anything changes using teh onchange function.
>
Terrible advice. What happens if they put in 1/2 of the data they want
to update, then have to close because they get called away?
Or, if it updates on the fly like you suggest, they update one field and
the system crashes, the power goes out, the internet connection drops -
whatever.
Someone trying to enter a new address comes to mind. You want all of
the changes or none of the changes.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Dirty Form Error Trapping?
am 22.10.2007 22:37:43 von Courtney
Jerry Stuckle wrote:
> The Natural Philosopher wrote:
>> Fester Bestertester wrote:
>>> Greetings,
>>>
>>> I'm an occasional php/mysql dabbler.
>>>
>>> I have a basic data form with a submit button. Unfortunately, it's
>>> still possible for the user to enter data changes and close the
>>> window, without clicking the submit button, thus losing the data.
>>>
>>> Can someone point me to a generic example of some code that will trap
>>> and handle this error?
>> Only way is via javascript.
>>
>> Something like "onunload submit".
>>
>> But the syntax is far more complex.
>>
>> Another way to achieve what you want is to use javascript to submit
>> the form any time anything changes using teh onchange function.
>>
>
> Terrible advice. What happens if they put in 1/2 of the data they want
> to update, then have to close because they get called away?
>
That depends. In some cases that is desirable behaviour, if the fields
are somewhat independent.
Oherwise an alert box on unloading, and ask them if they want to scrap
the data they have entered..
> Or, if it updates on the fly like you suggest, they update one field and
> the system crashes, the power goes out, the internet connection drops -
> whatever.
>
No problem really..it depends if the form comprises an atomic
transaction. Lots do not.
> Someone trying to enter a new address comes to mind. You want all of
> the changes or none of the changes.
>
>
Dunno. Here just changing the postcode woul probably be enough ;-)
However if you want an atomic transaction, use onchange to set a flag,
and submit to clear it, and on unload if the flag is still set, issue
warning.
Its fairly standard javascript.
Re: Dirty Form Error Trapping?
am 22.10.2007 23:06:54 von Lars Eighner
In our last episode, , the lovely and talented
Fester Bestertester broadcast on comp.lang.php:
> Greetings,
> I'm an occasional php/mysql dabbler.
> I have a basic data form with a submit button. Unfortunately, it's still
> possible for the user to enter data changes and close the window,
> without clicking the submit button, thus losing the data.
> Can someone point me to a generic example of some code that will trap
> and handle this error?
No PHP solution is possible to this problem. PHP works server-side. It has
no way of knowing what occurs in the browser. All can ever know is what
data is posted, and if the user does not submit the data, PHP must know
nothing.
--
Lars Eighner
Countdown: 455 days to go.
What do you do when you're debranded?
Re: Dirty Form Error Trapping?
am 23.10.2007 02:20:49 von Jerry Stuckle
The Natural Philosopher wrote:
> Jerry Stuckle wrote:
>> The Natural Philosopher wrote:
>>> Fester Bestertester wrote:
>>>> Greetings,
>>>>
>>>> I'm an occasional php/mysql dabbler.
>>>>
>>>> I have a basic data form with a submit button. Unfortunately, it's
>>>> still possible for the user to enter data changes and close the
>>>> window, without clicking the submit button, thus losing the data.
>>>>
>>>> Can someone point me to a generic example of some code that will
>>>> trap and handle this error?
>>> Only way is via javascript.
>>>
>>> Something like "onunload submit".
>>>
>>> But the syntax is far more complex.
>>>
>>> Another way to achieve what you want is to use javascript to submit
>>> the form any time anything changes using teh onchange function.
>>>
>>
>> Terrible advice. What happens if they put in 1/2 of the data they
>> want to update, then have to close because they get called away?
>>
>
> That depends. In some cases that is desirable behaviour, if the fields
> are somewhat independent.
>
> Oherwise an alert box on unloading, and ask them if they want to scrap
> the data they have entered..
>
And if they have a power failure, their internet goes down, their
browser crashes... Now what do they do?
>
>> Or, if it updates on the fly like you suggest, they update one field
>> and the system crashes, the power goes out, the internet connection
>> drops - whatever.
>>
>
> No problem really..it depends if the form comprises an atomic
> transaction. Lots do not.
>
True. Many do not comprise an atomic transaction. So updating only
part of the data is very bad.
>> Someone trying to enter a new address comes to mind. You want all of
>> the changes or none of the changes.
>>
>>
>
> Dunno. Here just changing the postcode woul probably be enough ;-)
>
Is it? What happens if I enter a new street address and the system goes
down? What happens to the city, state, postal code...
> However if you want an atomic transaction, use onchange to set a flag,
> and submit to clear it, and on unload if the flag is still set, issue
> warning.
>
> Its fairly standard javascript.
>
Which does you absolutely no good if you have one of the problems noted
above.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Dirty Form Error Trapping?
am 23.10.2007 14:36:46 von Jeff North
On Mon, 22 Oct 2007 09:45:31 -0700, in comp.lang.php Fester
Bestertester
wrote:
>| Greetings,
>|
>| I'm an occasional php/mysql dabbler.
>|
>| I have a basic data form with a submit button. Unfortunately, it's still
>| possible for the user to enter data changes and close the window,
>| without clicking the submit button, thus losing the data.
I would be asking why the users are doing this then find a solution.
>| Can someone point me to a generic example of some code that will trap
>| and handle this error?
-- ------------------------------------------------------------ -
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
-- ------------------------------------------------------------ -
Re: Dirty Form Error Trapping?
am 23.10.2007 14:57:59 von Captain Paralytic
On 22 Oct, 20:48, The Natural Philosopher wrote:
> Fester Bestertester wrote:
> > Greetings,
>
> > I'm an occasional php/mysql dabbler.
>
> > I have a basic data form with a submit button. Unfortunately, it's still
> > possible for the user to enter data changes and close the window,
> > without clicking the submit button, thus losing the data.
>
> > Can someone point me to a generic example of some code that will trap
> > and handle this error?
>
> Only way is via javascript.
>
> Something like "onunload submit".
Some sites (Google Groups and the BBC Radio Player are examples), will
pop up a javasript cofirmation dialogue if you try to leave the page
having already typed information in (in thecase of Google Groups), or
have selected a radio programme to listen to (in he case of the BBC
Radio Player).
Re: Dirty Form Error Trapping?
am 23.10.2007 15:11:37 von Jerry Stuckle
Captain Paralytic wrote:
> On 22 Oct, 20:48, The Natural Philosopher wrote:
>> Fester Bestertester wrote:
>>> Greetings,
>>> I'm an occasional php/mysql dabbler.
>>> I have a basic data form with a submit button. Unfortunately, it's still
>>> possible for the user to enter data changes and close the window,
>>> without clicking the submit button, thus losing the data.
>>> Can someone point me to a generic example of some code that will trap
>>> and handle this error?
>> Only way is via javascript.
>>
>> Something like "onunload submit".
>
> Some sites (Google Groups and the BBC Radio Player are examples), will
> pop up a javasript cofirmation dialogue if you try to leave the page
> having already typed information in (in thecase of Google Groups), or
> have selected a radio programme to listen to (in he case of the BBC
> Radio Player).
>
>
Which can be very annoying if you have javascript enabled.
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Re: Dirty Form Error Trapping?
am 23.10.2007 15:14:08 von Captain Paralytic
On 23 Oct, 14:11, Jerry Stuckle wrote:
> Captain Paralytic wrote:
> > On 22 Oct, 20:48, The Natural Philosopher wrote:
> >> Fester Bestertester wrote:
> >>> Greetings,
> >>> I'm an occasional php/mysql dabbler.
> >>> I have a basic data form with a submit button. Unfortunately, it's still
> >>> possible for the user to enter data changes and close the window,
> >>> without clicking the submit button, thus losing the data.
> >>> Can someone point me to a generic example of some code that will trap
> >>> and handle this error?
> >> Only way is via javascript.
>
> >> Something like "onunload submit".
>
> > Some sites (Google Groups and the BBC Radio Player are examples), will
> > pop up a javasript cofirmation dialogue if you try to leave the page
> > having already typed information in (in thecase of Google Groups), or
> > have selected a radio programme to listen to (in he case of the BBC
> > Radio Player).
>
> Which can be very annoying if you have javascript enabled.
>
But so can lots of warning popups on lots of applications. The good
answer is to always let the users have an option to switch them off.
Re: Dirty Form Error Trapping?
am 23.10.2007 16:28:59 von Shelly
"Jeff North" wrote in message
news:uiqrh31ag7s6el5cl90vch2h9mh9e5h6af@4ax.com...
> On Mon, 22 Oct 2007 09:45:31 -0700, in comp.lang.php Fester
> Bestertester
> wrote:
>
>>| Greetings,
>>|
>>| I'm an occasional php/mysql dabbler.
>>|
>>| I have a basic data form with a submit button. Unfortunately, it's still
>>| possible for the user to enter data changes and close the window,
>>| without clicking the submit button, thus losing the data.
>
> I would be asking why the users are doing this then find a solution.
>
>>| Can someone point me to a generic example of some code that will trap
>>| and handle this error?
A "submit" button on a form has a reason for existence. There have been
MANY times that I have entered data on a form and changed my mind before
"submit"ing. I simply closed the window and all was gone! That is the
EXPECTED behavior. If a user is annoyed that this happened, then he should
learn how to use his computer! If data are to be entered whether or not he
clicks the "submit" button, then by all means get rid of that button!
Simply put, I totally disagree with the use of the word "Unfortunately".
Rather, I would have said "dammit" (or worse!) if the data had actually been
entered when I closed the window without clicking "submit".
Shelly
Re: Dirty Form Error Trapping?
am 24.10.2007 06:13:32 von Jeff North
On Tue, 23 Oct 2007 10:28:59 -0400, in comp.lang.php "Shelly"
<13hs19havvep5d8@corp.supernews.com> wrote:
>|
>| "Jeff North" wrote in message
>| news:uiqrh31ag7s6el5cl90vch2h9mh9e5h6af@4ax.com...
>| > On Mon, 22 Oct 2007 09:45:31 -0700, in comp.lang.php Fester
>| > Bestertester
>| > wrote:
>| >
>| >>| Greetings,
>| >>|
>| >>| I'm an occasional php/mysql dabbler.
>| >>|
>| >>| I have a basic data form with a submit button. Unfortunately, it's still
>| >>| possible for the user to enter data changes and close the window,
>| >>| without clicking the submit button, thus losing the data.
>| >
>| > I would be asking why the users are doing this then find a solution.
>| >
>| >>| Can someone point me to a generic example of some code that will trap
>| >>| and handle this error?
>|
>| A "submit" button on a form has a reason for existence. There have been
>| MANY times that I have entered data on a form and changed my mind before
>| "submit"ing. I simply closed the window and all was gone! That is the
>| EXPECTED behavior.
I agree. We've all done that at one time or other.
>| If a user is annoyed that this happened, then he should
>| learn how to use his computer!
Not necessarily so. The next button could be too close to the close
button and people are accidentally clicking the close button. Making
the next button slightly bigger (an easier target) would solve the
problem.
>| If data are to be entered whether or not he
>| clicks the "submit" button, then by all means get rid of that button!
>|
>| Simply put, I totally disagree with the use of the word "Unfortunately".
>| Rather, I would have said "dammit" (or worse!) if the data had actually been
>| entered when I closed the window without clicking "submit".
>|
>| Shelly
>|
-- ------------------------------------------------------------ -
jnorthau@yourpantsyahoo.com.au : Remove your pants to reply
-- ------------------------------------------------------------ -
Re: Dirty Form Error Trapping?
am 26.10.2007 23:33:10 von Fester Bestertester
Shelly wrote:
> A "submit" button on a form has a reason for existence. There have been
> MANY times that I have entered data on a form and changed my mind before
> "submit"ing. I simply closed the window and all was gone! That is the
> EXPECTED behavior. If a user is annoyed that this happened, then he should
> learn how to use his computer! If data are to be entered whether or not he
> clicks the "submit" button, then by all means get rid of that button!
>
> Simply put, I totally disagree with the use of the word "Unfortunately".
> Rather, I would have said "dammit" (or worse!) if the data had actually been
> entered when I closed the window without clicking "submit".
Actually this answer kind of reflects my initial reaction on hearing the
issue come up in the first place. My inclination was to ask, "so, if you
go to your bank's web site and enter all the information for a transfer
of funds from one account to another and then just click the "x" window,
do you assume the transaction went through?"
I sort of can't blame the users though. The functional people designed
this particular software usage survey form in such a way that it has
dozens of fields, for dozens of possible types of software. The result
is that the user scrolls down, enters some numbers at the bottom of the
form, and then forgets that there's a "Submit" button back at the top.
I've remedied this by creating several new instances of the Submit
button throughout the form, so that at least one instance is always
visible, and by placing a text reminder at the top of the form.
Hopefully that will do the trick.
Re: Dirty Form Error Trapping?
am 27.10.2007 14:47:20 von Norman Peelman
Fester Bestertester wrote:
> Shelly wrote:
>> A "submit" button on a form has a reason for existence. There have
>> been MANY times that I have entered data on a form and changed my mind
>> before "submit"ing. I simply closed the window and all was gone!
>> That is the EXPECTED behavior. If a user is annoyed that this
>> happened, then he should learn how to use his computer! If data are
>> to be entered whether or not he clicks the "submit" button, then by
>> all means get rid of that button!
>>
>> Simply put, I totally disagree with the use of the word
>> "Unfortunately". Rather, I would have said "dammit" (or worse!) if the
>> data had actually been entered when I closed the window without
>> clicking "submit".
>
> Actually this answer kind of reflects my initial reaction on hearing the
> issue come up in the first place. My inclination was to ask, "so, if you
> go to your bank's web site and enter all the information for a transfer
> of funds from one account to another and then just click the "x" window,
> do you assume the transaction went through?"
>
> I sort of can't blame the users though. The functional people designed
> this particular software usage survey form in such a way that it has
> dozens of fields, for dozens of possible types of software. The result
> is that the user scrolls down, enters some numbers at the bottom of the
> form, and then forgets that there's a "Submit" button back at the top.
>
> I've remedied this by creating several new instances of the Submit
> button throughout the form, so that at least one instance is always
> visible, and by placing a text reminder at the top of the form.
> Hopefully that will do the trick.
I would put a button at the top and bottom with reminders
throughout... too many buttons and someone will think they can update
info periodically (which is still not what you want).
My opinion is this, a form is presented with anticipation of all
fields being filled in (minus non-required fields). You must write your
script to handle the form properly to begin with. Don't update anything
until the form is submitted and you have checked all appropriate fields
have been entered (or changed). If not give them the form back with
hints on the appropriate entries (I use CSS). If a user closes their
window without subbmitting the form then assume that they did not want
to submit the form. If you want to use cookies so a user can come back
later that's fine... just don't do any updates until the form is
submitted and verified first.
You might look at breaking the form up into smaller pieces and
feeding it to the users based on each previous part (use cookies or
sessions to track). Have your script dynamically produce the form parts
as it reacts to previous selections... no javascript needed. AT the end
when all info has been gathered and verified do your stuff.
Norm