通过页面传递数据 [英] Passing data through pages

查看:32
本文介绍了通过页面传递数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我当前项目的一部分是提供申请表。这个表单需要获得相当多的数据,因此我不是在一个页面上有一个非常长的表单,而是将数据分成3页。每个页面都会随时验证输入,以便最终页面可以将其全部提交到数据库,因为它知道它是有效的。


我不知道该怎么做才能通过数据通过三页。每个页面都需要将它的数据传递到下一页,这样当最后一页完成时,所有数据都可以发送到服务器。


所以每页都有使用method =" post"上的表单以及将其带入流程下一步的行动。是否有办法继续将越来越多的数据传递到链中?我想我每次都可以写入数据库,但我希望避免这样做,这样如果流程中止,我就不用担心了。


这一切都是合理?简而言之,我如何通过3页传递数据到服务器上?


非常感谢

Nathan

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

推荐答案





我当前项目的一部分是提供申请表。这个表单需要获得相当多的数据,因此我不是在一个页面上有一个非常长的表单,而是将数据分成3页。每个页面都会随时验证输入,以便最终页面可以将其全部提交到数据库,因为它知道它是有效的。


我不知道该怎么做才能通过数据通过三页。每个页面都需要将它的数据传递到下一页,这样当最后一页完成时,所有数据都可以发送到服务器。


所以每页都有使用method =" post"上的表单以及将其带入流程下一步的行动。是否有办法继续将越来越多的数据传递到链中?我想我每次都可以写入数据库,但我希望避免这样做,这样如果流程中止,我就不用担心了。


这一切都是合理?简而言之,我如何将数据传递到3页并进入服务器?


非常感谢

Nathan
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






只读第一行,我的第一个解决方案是简单地将每个页面的结果写入数据库。但是你说你不想这样做。


另一种解决方案是通过POST或GET将它们传递到下一页。您可以在表单中使用隐藏变量(例如< input type =" hidden" name =" password-from-page-1" value =" previous-entered-password">),但此方法不是非常专业,恕我直言,因为每页都有一个越来越大的表格。


您可以执行以下操作:将每个页面的用户输入写入数据库。如果用户中止,只需删除已写入数据库的数据。每当新用户开始填写表单时,您可以先检查前一个用户是否中止,如果是,请检查以前的输入是否已被删除。如果没有,请删除它。这应该保持数据库清洁。


然而,如果你不想使用数据库,唯一的解决方案是使用POST或GET,因为无状态的性质HTTP(这意味着HTTP中不存在允许跟踪用户或数据的固有机制)。


我希望这能帮助你以某种方式:)


亲切问候。

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="previously-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.






只读第一行,我的第一个解决方案是简单地将每个页面的结果写入数据库。但是你说你不想这样做。


另一种解决方案是通过POST或GET将它们传递到下一页。您可以在表单中使用隐藏变量(例如< input type =" hidden" name =" password-from-page-1" value =" previous-entered-password">),但此方法不是非常专业,恕我直言,因为每页都有一个越来越大的表格。


您可以执行以下操作:将每个页面的用户输入写入数据库。如果用户中止,只需删除已写入数据库的数据。每当新用户开始填写表单时,您可以先检查前一个用户是否中止,如果是,请检查以前的输入是否已被删除。如果没有,请删除它。这应该保持数据库清洁。


然而,如果你不想使用数据库,唯一的解决方案是使用POST或GET,因为无状态的性质HTTP(这意味着HTTP中不存在允许跟踪用户或数据的固有机制)。


我希望这能帮助你以某种方式:)


亲切的问候。
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="previously-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.



我认为在每个阶段写入数据库将是我的方式,一些聪明的垃圾收集例程应该是相当安全的。我想,当我从头开始这个时,我有机会对数据完整性真的很偏执,真的很肛门关于数据库的内容以及什么时候。


它确实看起来像尽管如此。


感谢您的提示。

nathj

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


请记住,两个或更多用户可以填写表格同时,所以一定要使用session_id之类的,以确保它是你在发布时提取的正确数据。


另一种方法是,使用隐藏的div与您的表单,并在nextpress您可以验证表单,如果它是有效的你隐藏它并显示下一个表单。


这保险一些交通和等待表单步骤之间的时间。


您还可以使用javascript动态创建div,如果您希望根据某些表单字段提供不同的数据,这非常有用这个解决方案的好处在于你不必担心未提交的数据等等。


退出是当然这些5%没有激活javascript的人....


我总是说,如果你可以避免任务(比如cl)为以前的用户而努力)然后避免它:)
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 :)


这篇关于通过页面传递数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆