473,498 Members | 98 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 3861
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('Location: form_output.php');
exit('Redirected <a href="form_output.php">here</a>.');
?>

and

<?php // form output script
session_start();
if (isset($_SESSION['userdata']) {
$useradata = $_SESSION['userdata'];
} else {
$userdata = ''; // or some other default value
}
?>
<form method="post" action="form_process.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
3190
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...
2
1391
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...
1
2247
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...
5
5249
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...
9
2532
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...
2
1882
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...
12
2436
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...
4
2579
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...
1
2897
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...
0
6998
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
7200
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...
1
6884
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...
1
4904
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...
0
4586
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...
0
3090
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...
0
3078
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
651
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
287
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...

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.