473,326 Members | 2,012 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Dirty Form Error Trapping?

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?
Oct 22 '07 #1
18 1665
"Fester Bestertester" <wh*********@mad.netwrote in message
news:ff**********@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?
Oct 22 '07 #2
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.
js*******@attglobal.net
==================

Oct 22 '07 #3
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.
Oct 22 '07 #4
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?

Oct 22 '07 #5
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.
Oct 22 '07 #6
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.
js*******@attglobal.net
==================

Oct 22 '07 #7
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.
js*******@attglobal.net
==================

Oct 22 '07 #8
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.
Oct 22 '07 #9
In our last episode, <ff**********@gondor.sdsu.edu>, 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 <http://larseighner.com/ <http://myspace.com/larseighner>
Countdown: 455 days to go.
What do you do when you're debranded?
Oct 22 '07 #10
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.
js*******@attglobal.net
==================

Oct 23 '07 #11
On Mon, 22 Oct 2007 09:45:31 -0700, in comp.lang.php Fester
Bestertester <wh*********@mad.net>
<ff**********@gondor.sdsu.eduwrote:
>| 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?
-- -------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Oct 23 '07 #12
On 22 Oct, 20:48, The Natural Philosopher <a...@b.cwrote:
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).

Oct 23 '07 #13
Captain Paralytic wrote:
On 22 Oct, 20:48, The Natural Philosopher <a...@b.cwrote:
>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.
js*******@attglobal.net
==================

Oct 23 '07 #14
On 23 Oct, 14:11, Jerry Stuckle <jstuck...@attglobal.netwrote:
Captain Paralytic wrote:
On 22 Oct, 20:48, The Natural Philosopher <a...@b.cwrote:
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.
Oct 23 '07 #15

"Jeff North" <jn******@yahoo.com.auwrote in message
news:ui********************************@4ax.com...
On Mon, 22 Oct 2007 09:45:31 -0700, in comp.lang.php Fester
Bestertester <wh*********@mad.net>
<ff**********@gondor.sdsu.eduwrote:
>>| 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
Oct 23 '07 #16
On Tue, 23 Oct 2007 10:28:59 -0400, in comp.lang.php "Shelly"
<sh************@asap-consult.com>
<13*************@corp.supernews.comwrote:
>|
| "Jeff North" <jn******@yahoo.com.auwrote in message
| news:ui********************************@4ax.com...
| On Mon, 22 Oct 2007 09:45:31 -0700, in comp.lang.php Fester
| Bestertester <wh*********@mad.net>
| <ff**********@gondor.sdsu.eduwrote:
| >
| >>| 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
|
-- -------------------------------------------------------------
jn******@yourpantsyahoo.com.au : Remove your pants to reply
-- -------------------------------------------------------------
Oct 24 '07 #17
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.
Oct 26 '07 #18
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
Oct 27 '07 #19

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

Similar topics

15
by: Rey | last post by:
Howdy all. Appreciate your help with several problems I'm having: I'm trying to determine if the Visit subform (subformVisits) has a new record or been changed, i.e. dirty. The form that...
2
by: Salad | last post by:
A97. I have a command button to save and exit. I had the code If Me.Dirty Then Docmd.RunCommand acCmdSaveRecord ...more code endif I was getting an error because a value was not getting...
15
by: Steve | last post by:
I have a form with about 25 fields. In the BeforeUpdate event of the form, I have code that sets the default value of each field to its current value. For a new record, I can put the focus in any...
3
by: Rolan | last post by:
I need assistance regarding code needed to prevent someone from opening a form if a table field name(s) has been changed. For example, there is existing code to check for certain data based on...
3
by: Smriti Dev | last post by:
Hi There, I have the following code and when I try to run it, I get a type mismatch error. I would really appreciate your help with this. Thanks kindly, smriti --- Private Sub cmdOK_Click()
9
by: Susan Bricker | last post by:
I am currently using the OnDirty event of a Form to detect whether any fields have been modified. I set a boolean variable. Then, if the Close button is clicked before the Save button, I can put...
1
by: Shawn Eary | last post by:
Hello Everyone: I used VB.NET 2003 Standard to create a User Control which I named PersonControl and then overrode its OnLoad routine to use SQL commands to populate its sub-controls. When I...
10
by: Norm | last post by:
I must not be understanding something about the use of forms in VB.Net that is different from VB. I have one form running in the background with an icon in the task bar. Right clicking on the icon...
1
by: lesperancer | last post by:
I've got a form that is opened in readonly mode and no fields can be changed, great but if I click on a combo box that has an _enter() event that sets a field on my form to a value (albeit the...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.