473,624 Members | 2,651 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Passing data through pages

nathj
938 Recognized Expert Contributor
Hi,

Part of one of my current projects is to provide an application form. This form needs to get quite a bit of data, so rather than have one really long form on one page I have split the data over 3 pages. Each page validates the input as you go so that the final page can submit it all to the database knowing that it is valid.

What I don't know how to do is pass the data through the three pages. Each page needs to pass it's data onto the next page so that by the time the final page is complete all the data can be sent to the server.

So each page has a form on it using method="post" and action that takes it to the next step of the process. Is there are a way to keep passing the increasing amount of data down the chain? I figure I could write to the database every time but I was hoping to avoid that so that if the process s aborted I don't have to worry about it.

Does that all make sense? In short how can I pass data through 3 pages and onto the server?

Many thanks
Nathan
Jun 28 '07 #1
10 2550
NoComment
16 New Member
Hi,

Part of one of my current projects is to provide an application form. This form needs to get quite a bit of data, so rather than have one really long form on one page I have split the data over 3 pages. Each page validates the input as you go so that the final page can submit it all to the database knowing that it is valid.

What I don't know how to do is pass the data through the three pages. Each page needs to pass it's data onto the next page so that by the time the final page is complete all the data can be sent to the server.

So each page has a form on it using method="post" and action that takes it to the next step of the process. Is there are a way to keep passing the increasing amount of data down the chain? I figure I could write to the database every time but I was hoping to avoid that so that if the process s aborted I don't have to worry about it.

Does that all make sense? In short how can I pass data through 3 pages and onto the server?

Many thanks
Nathan
Hi

Reading just the first lines, my first solution was to simply write the results of each page to the database. But you said you don't want to do that.

Another solution would be to pass them on to the next page via POST or GET. You could use hidden variables in your forms (like <input type="hidden" name ="password-from-page-1" value="previous ly-entered-password">), but this approach is not very professional, IMHO, since you have an increasingly bigger form with each page.

You could do the following: write the user input of each page to the database. if the user aborts, just delete the data you already wrote to the database. And everytime a new user starts filling out your form, you could first check if the previous user aborted and if so, check if the previous input has already been deleted. If not, delete it then. This should keep the database clean.

Yet, if you don't want to use a database for that, the only solution would be to use POST or GET due to the stateless nature of HTTP (which means there is no such inherent mechanism in HTTP that allows tracking of users or data).

I hope this helps you somehow :)

Kind regards.
Jun 28 '07 #2
nathj
938 Recognized Expert Contributor
Hi

Reading just the first lines, my first solution was to simply write the results of each page to the database. But you said you don't want to do that.

Another solution would be to pass them on to the next page via POST or GET. You could use hidden variables in your forms (like <input type="hidden" name ="password-from-page-1" value="previous ly-entered-password">), but this approach is not very professional, IMHO, since you have an increasingly bigger form with each page.

You could do the following: write the user input of each page to the database. if the user aborts, just delete the data you already wrote to the database. And everytime a new user starts filling out your form, you could first check if the previous user aborted and if so, check if the previous input has already been deleted. If not, delete it then. This should keep the database clean.

Yet, if you don't want to use a database for that, the only solution would be to use POST or GET due to the stateless nature of HTTP (which means there is no such inherent mechanism in HTTP that allows tracking of users or data).

I hope this helps you somehow :)

Kind regards.
I think that writing to the DB at each stage will be the way I go, with some clever garbage collection routines it should be fairly safe. I guess that as I am starting this from scratch I have the chance to be really paranoid about data integrity and really anal about what goes to the DB and when.

It does look like the best solution though.

Thanks for the tip.
nathj
Jun 28 '07 #3
ronnil
134 Recognized Expert New Member
keep in mind that two or more users can fill out the form at the same time, so be sure to use session_id or the like to be sure it's the right data you extract in time of posting.

Another way to do this, is to use hidden divs with your form, and on nextpress you can validate the form, if it's valid you hide it and show the next form.

this safes some trafic and waiting time between form steps.

You can also create the divs dynamically with javascript as you go along, this is great if you want to have different data depending on some of the form field's values.

the great thing about this solution is that you don't have to worry about unsubmitted data, etc.

the backdraw is ofcourse these 5% who don't have javascript activated....

I always say, if you can avoid a task (like cleaning up for previous users) then avoid it :)
Jun 28 '07 #4
pbmods
5,821 Recognized Expert Expert
Heya, Nathan.

You can store the data in $_SESSION. Just make sure you call session_start() at the beginning of each of your scripts.

For more information:
http://php.net/manual/en/ref.session.php
Jun 28 '07 #5
NoComment
16 New Member
Heya, Nathan.

You can store the data in $_SESSION. Just make sure you call session_start() at the beginning of each of your scripts.

For more information:
http://php.net/manual/en/ref.session.php
You are right, it's a solution that didn't come to my mind. And even when cookies are disabled, the session ID is transferred by a GET parameter, right?
Jun 28 '07 #6
pbmods
5,821 Recognized Expert Expert
Heya, NoComment.

And even when cookies are disabled, the session ID is transferred by a GET parameter, right?
Yup yup.
Jun 28 '07 #7
nathj
938 Recognized Expert Contributor
Looks like its going to be making use of $_SESSION.

As for form validation, the next button isn't actually available until the form is 100% valid. I validate the data as the users enters it. I would show you this but the form is currently part of a site that is local only.

I have bookmarked this page me to try out the ideas tomorrow.

Thanks for all your help, if I get stuck I'll give a shout.

Cheers
Nathan
Jun 28 '07 #8
pbmods
5,821 Recognized Expert Expert
Heya, nath.

Glad to hear you got it working.

Good luck with your project, and if you ever need anything, post back anytime!
Jun 28 '07 #9
shailpatel83
1 New Member
Here is the good article that explains hows you can pass data between web pages.

[URLs DELETED]
Feb 9 '10 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

1
7779
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains: ---------------------------------------------------------------------------- <?php ini_set("session.use_cookies", "off"); ini_set("session.use_trans_sid", "on"); session_start(); $_SESSION = ""; $_SESSION = ""; echo "<form method='POST' action='login.php'>
1
4594
by: Kevin Lyons | last post by:
Hello, I am trying to get all of my form elements passed correctly from the following URL: http://www.dslextreme.com/users/kevinlyons/selectBoxes.html to the following URL: http://www.dslextreme.com/users/kevinlyons/selectResults.html I am passing name, email, countries, cities, products, courses, etc. The others display as they should on the subsequent page,
3
4747
by: Simon Harvey | last post by:
Hi, In my application I get lots of different sorts of information from databases. As such, a lot of information is stored in DataSets and DataTable objects. Up until now, I have been passing around chunks of data in DataTables/DataSets, simply because that was the format that they were in when the data was taken from the database. Now, I know this maybe a pretty silly question with a standard "it depends" answer, but I'm going to...
4
2345
by: Gibs | last post by:
Hi I have two aspx pages in a frame and in the top page i am creating the controls dynamically and putting in a place holder. I have a hyperlink in this page to populate the data in the bottom aspx page. When the user clicks this hyperlink i need to populate the bottom aspx pagebased on the user imputs. So i need to pass the values from the top aspx page to bottom aspx page. how can i achieve this. Please give some ideas...
5
2115
by: Rod | last post by:
I've written 2 ASP.NET applications (I've worked on one with a team and another by myself). In my ASP.NET pages, when saving data to a backend database I've done it by using the click event of a button and just using the data during postback. Now, however, I've got a WebForm that I'll be working on, and it is going to collect more data than I have collected from the user in the past. I want to be able to attempt to save each part and if...
1
2700
by: olduncleamos | last post by:
Hello all. With a background in ASP, I am finding the work required for passing values between pages mystifying. For various obvious reasons, I have eliminated using cookies and session to store state data. The only ASP.NET options left is to use the Server.Transfer to transfer to page 2 from page 1, and then use the context to get whatever values in page 1 from page 2. I do find this indeed a very elegant solution as now I can pass...
2
3005
by: Roy | last post by:
Hey all, Is it possible to pass session variables between pages in separate projects? For example: inetpub\thisproject\blah.aspx has a session variable and response.redirects the user to inetpub\anotherproject\test.aspx
7
1873
by: Smokey Grindle | last post by:
For a website that has users logged into it using sessions, its it best to pass data between pages in session variables or through query strings?
3
2277
by: dbuchanan | last post by:
newbie question What are the various ways that data can be passed between pages. For example; How is data about the logged in user passed to subsequent pages Thank you, Doug
0
8249
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...
0
8179
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
8685
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8633
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...
0
7176
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
4084
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...
1
2613
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
1
1797
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1493
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.