473,399 Members | 4,254 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,399 software developers and data experts.

Checking if a form has been submitted.

Hi,
I have a html form where all the details are saved in a MySQL database
that uses PHP to insert the data into the database.
The problem I'm having is that if people dont submit the form then the
data doesnt get saved to the database.
Does anyone know a way to show a message e.g. "Form has not been saved"
if the user tries to exit the page without pressing the submit button?
or does anyone have an example of this?
Thanks,
Tony.

Aug 24 '05 #1
2 2714

clarket wrote:
Does anyone know a way to show a message e.g. "Form has not been saved"
if the user tries to exit the page without pressing the submit button?

How does a user 'exit' a page? If you had meant clicking on other
links, then add a handler to all your links. This can be tedious if you
have a lot of links - unless you have a good editor - you could change
a link like this - <a href="http://www.something.com">... to something
like this - <a
href="javascript:dataNotSaved('http://www.something.com')"> and
function dataNotSaved(url) {
alert('Data not saved');
document.location.href = url;
}
If you have links that open a new window, or load a page in a frame,
then you could handle it by having an ID to each anchor tag, finding
the 'target' attribute of the element and loading the URL
appropriately.

Aug 24 '05 #2
Use an onClose or onUnload (whatever its name) event set to fire if a
certain event hasn't happened or variable isn't set. Have your submit
button set the variable, and onUnload check for it. Googling, it seems
that it is onunload and onclose.

Aug 24 '05 #3

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

Similar topics

4
by: Andrew Williams | last post by:
Does anyone know of a way to quickly validate an HTML web form? I need to make sure that certain fields on my form actually contain data and are not submitted blank. I have tried using...
0
by: Peter Rooney | last post by:
Hi, I have built an application that collects data submitted from an asp form, this data is then written to a file with an .req extension, and the file is saved into a directory on the server,...
13
by: Dan R Brown | last post by:
I have a large form that is generated dynamically in a jsp using xml / xslt. So, to break up this form into several "tabbed" sections, I break up the form using <div> tags. Each <div...
1
by: kim | last post by:
I'm trying to check my radio buttons before the form is submitted. The radio button names are the same(pend) because only one should be selected. I also would like to know how to make sure if a...
5
by: Richard Cornford | last post by:
I am interested in hearing opinions on the semantic meaning of FORM (elements) in HTML. I have to start of apologising because this question arose in a context that is not applicable to the...
10
by: Samir | last post by:
Say I have 4 forms, all four have different numbers of text boxes. is there a script that I can use to check to make sure everything on the form is not blank?
13
by: aundro | last post by:
Hello, I've been looking on the web for a solution to this problem: I create a set of checkboxes, and 2 buttons: - one is labeled "All" - the other is labeled "None" Clicking "All" is...
16
by: whyyyy | last post by:
The script below works fine if the form is filled out and submitted. But a (blank) e-mail is sent whenever the page loads, even when the form is not submitted. I would like to receive the e-mail...
5
by: keeps21 | last post by:
A little problem I've run into is the following. I have a script that allows a user to edit a story. I have an HTML form for title and main_text which gets it's values by pulling the selected...
1
by: geetamadhavi | last post by:
Hi All, I have developed a php applciaiton where a new window is opening on checking the whether valid user orntot how to make that in same window after checking i have die(' not valid user ' ); i...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.