473,763 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

losing form data

i am validating form data, but when i redirect the user back to the
form page to correct the errors, all of the data they entered has
disappeared.

Please Help.

Thanks
Jul 17 '05 #1
2 3877
digihoo wrote:
i am validating form data, but when i redirect the user back to the
form page to correct the errors, all of the data they entered has
disappeared.


The browser only displays what you send.
If you want to send the same data a user submitted, you have to save it
between the form processing script and the script that outputs that
form. I'd do that with session variables:

<?php // form processing script
session_start() ;
if (isset($_POST['userdata']) {
validate_data($ _POST); // define according to your needs
$_SESSION['userdata'] = $_POST['userdata'];
}
header('Locatio n: form_output.php ');
exit('Redirecte d <a href="form_outp ut.php">here</a>.');
?>

and

<?php // form output script
session_start() ;
if (isset($_SESSIO N['userdata']) {
$useradata = $_SESSION['userdata'];
} else {
$userdata = ''; // or some other default value
}
?>
<form method="post" action="form_pr ocess.php">
<input type="text" name="userdata" value="<?php echo $userdata; ?>" />
<input type="submit">
</form>

Happy Coding :-)

--
I have a spam filter working.
To mail me include "urkxvq" (with or without the quotes)
in the subject line, or your mail will be ruthlessly discarded.
Jul 17 '05 #2
i should have been more specific here. the form also loses its data if
the user just clicks the back button - without actually submitting the
data.

when they click forward to the form again, the data is also gone.

i was told that this is caused by a bug in IE 6, and to put:

header("Cache-control: private");

in the code before any HTML. however, this didn't solve the problem.

is there a way to prevent form data from disappearing, whether or not
it has been submitted into post variables?

Thanks
Jul 17 '05 #3

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

Similar topics

32
3228
by: Neil Ginsberg | last post by:
We're using SQL Server 7 with an Access 2000 MDB as a front end with ODBC linked tables. I recently created a new set of tables for the app, and users are complaining that unsaved data is being lost when they move to a new record. This seems to be the case when there are multiple users. When there is a single user using it, we don't seem to have that problem. It seems that we had this problem when we first converted from an MDB back end...
2
1409
by: mdulaney | last post by:
I have a front end database file linked to a back end database file. Periodically (every few months?), a form name frmStallSvcContract which is based on a query comes up without data. The fields are present but there is not any data shown. The data shows up in the underlying query. My fix that always works is to reimport a copy of the form from a backup of the database. When I do that I can see the data fine. However, I would like to solve...
1
2275
by: blue | last post by:
My app draws a bunch of tables on the page and has a form for the user to enter data and submit. The form is contained within a User Control called DecisionCtl. When they submit the form, a bunch of db updates are performed and then page needs to be redrawn with the new table that is generated from the data they entered. After the DB updates, the DecisionCtl bubbles an event up to its container (the Page). The OnBubbleEvent removes...
5
5291
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the sessionstate inproc mode and users are randomly losing their session. I do not believe it is happening across all users at one time. It seems to happen to different users at different times, but I am only going off heresay. The aspnet worker...
9
2546
by: Adrian Parker | last post by:
We have a website that works everywhere but on a few PCs on this one site.. Asp.Net 1.1 Server = Windows 2003 Client = XP In the web.config we use - cookieless="false" in the browser settings they have "Always allow session cookies" set to true When the browser connects to the website the first page sets a session variable called "user_ref" to something and then calls another page. If on
2
1900
by: Aspnot | last post by:
I have a TabControl that is on a form that is bound to a DataSet. I bind the dataset to the form in the Form_Load event. The TabControl has 2 TabPages. The first TabPage contains a button and a textbox. Scenario 1: I call BindingContext(ds.TableName).AddNew(), then I click the button and that populates some text into the textbox on the first tab. Then I switch over to Tab2 and back to Tab1. The text that was programatically inserted...
12
2460
by: Michael Lang | last post by:
I'm adding checkbox controls to a panel in a post back, I then have a second post back in which I attempt to process the checkbox controls however they seem to have disappeared off the panel. The following code demonstrates what I'm trying to do. Can anyone explain why there is no checkbox control on the panel when btnTwo is clicked? ...
4
2606
by: otterbyte | last post by:
Hi, I have a bit of code which is confusing me to no end. Here are the basics: 1) The class module is being used in the module of a form. 2) There is an instance of the object declared at the form level, and instantiated in the Load event of the form. This instance holds the "current" values (based on data in a table), and it's called ordCurrent.
1
2912
by: Andy | last post by:
Hi Gang I need help. I have an ASP application that in a nutshell allows data entry on a main page. The problem is I'll have users that enter some data and save it. Then they'll enter some more data and then leave it for 30 mins, 2 hours or whatever. So when they come back they've lost the session state and when they try to save their data, the application goes to a friendly error page saying they've lost the state.
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
9938
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
8822
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...
1
7366
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6642
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();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5406
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
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
3
3523
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.