473,657 Members | 2,458 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 2728

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.c om">... to something
like this - <a
href="javascrip t:dataNotSaved( 'http://www.something.c om')"> and
function dataNotSaved(ur l) {
alert('Data not saved');
document.locati on.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
2359
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 client-side Javascript validation which flags up when a field is empty but the form is still submitted. Here is the ASP code I am using to submit the form to an e- mail with CDONTS:
0
1009
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, this folder is monitored by a seperated application that picks up the files with the ..req extension and the writes the results to the data submitted back to the file and the re-names it with a .PAR extension. What I want to do is re-direct the...
13
40717
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 style="display:none"> can be displayed by setting the style attribute to "display:", or hidden with "display:none". This gives the illusion that the person filling out the form is switching from page to page...without the overhead of extra hits on the server,...
1
3421
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 radio button has been selected, a text box the on form has to be completed before the form is submitted. In other words if the Cat radio button is selected then the user has to enter data in the color text box before the form will be submitted.
5
6084
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 Internet. Specifically, marking up a document that will contain multiple related form controls (intended exclusively for client-side scripting) that would never be intended to be submitted. I realise that that concept is a non-starter in an Internet...
10
1371
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
31339
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 supposed to check all the checkboxes, which it does (that's not rocket science ;), but the 'onchange' event does not get triggered.
16
3142
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 only when the form is submitted <%@LANGUAGE="VBSCRIPT"%> <% Set MyMail=CreateObject("CDO.Message")
5
2474
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 data from the database. If the user either i) doesn't change anything, and then saves. or
1
2003
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 even tried with echo also how to solve this the message should come under in the same window only see my code it is program ---- <?php // Connects to your Database mysql_connect('localhost', 'root', 'epara') or die(mysql_error());
0
8325
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8742
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8518
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8621
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7354
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5643
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.