Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions

Reply
 
Thread Tools Display Modes
  #1  
Old 01-21-2005, 11:25 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default Looking for a safe and efficient way to "carry" data from page to page

Is there a way for me to "carry" a chunk of information around from one screen to another without using cookies?

For example, let's say I have a table that has a questions for a survey I want people to take. If I want the people to answer the questions one at a time and not all on the same page with a single click, can I query the database once and get all the questions and then use that info to show the first question, get a response, show the second question, etc.?

What I am trying to avoid is having to query for the first question, get the response, query for the second question, etc.

Amy
Reply With Quote
  #2  
Old 01-21-2005, 11:40 AM
Marco van Herwaarden Marco van Herwaarden is offline
 
Join Date: Jul 2004
Posts: 25,415
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could put all in an array and post that in a hidden field. Security on this would be a different mather.
Reply With Quote
  #3  
Old 01-21-2005, 11:41 AM
Guy G Guy G is offline
 
Join Date: Nov 2004
Posts: 250
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by amykhar
Is there a way for me to "carry" a chunk of information around from one screen to another without using cookies?

For example, let's say I have a table that has a questions for a survey I want people to take. If I want the people to answer the questions one at a time and not all on the same page with a single click, can I query the database once and get all the questions and then use that info to show the first question, get a response, show the second question, etc.?

What I am trying to avoid is having to query for the first question, get the response, query for the second question, etc.

Amy
instead of carrying the info you could just have it on one page and switch everytime for each question...

like
question.php?ask=question1
question.php?ask=question2
question.php?ask=question3
...

or im wrong :/
Reply With Quote
  #4  
Old 01-21-2005, 11:43 AM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You could extend the session table.
Reply With Quote
  #5  
Old 01-21-2005, 12:29 PM
sabret00the's Avatar
sabret00the sabret00the is offline
 
Join Date: Jan 2003
Location: London
Posts: 5,268
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

couldn't you serialize the data to scramble it? and then carry it all in a hidden form field?

i.e.

PHP Code:
$oldanswers unserialize($answers);
$newanswers $_POST['answers'];
$newanswers .= $oldanswers;
$answers serialize($newanswers); 

HTML Code:
<input type="hidden" name="questions" value="$answers" />
i probably mean something that's not serliaze but you get what i mean, granted i have no experience of this, but the idea works.
Reply With Quote
  #6  
Old 01-21-2005, 12:33 PM
Andreas's Avatar
Andreas Andreas is offline
 
Join Date: Jan 2004
Location: Germany
Posts: 6,863
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No matter if you carry the data by hidden fields, cookies or within the URL:
It can be modified by the user.
To prevent this you would have to hash the data with some secret to make sure it has not been modified.
Reply With Quote
  #7  
Old 01-21-2005, 04:41 PM
Xenon's Avatar
Xenon Xenon is offline
 
Join Date: Oct 2001
Location: Bavaria
Posts: 12,878
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Personally i think Kirby's way is the best

add a field to the sessions table and there put in the serialized data of the already answered question.
Reply With Quote
  #8  
Old 01-21-2005, 05:02 PM
Dean C's Avatar
Dean C Dean C is offline
 
Join Date: Jan 2002
Location: England
Posts: 9,071
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hmm sessions are ideal for carrying answers to survey questions across pages. The only other way I'd do it is serializing the $_POST info as sabe pointed out But if people want to cheat they can cheat. It's a sacrifice you have to make
Reply With Quote
  #9  
Old 01-21-2005, 05:04 PM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for all the ideas, guys.
Reply With Quote
  #10  
Old 01-22-2005, 12:59 AM
amykhar's Avatar
amykhar amykhar is offline
 
Join Date: Oct 2001
Location: PA
Posts: 4,438
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Efficiency question: What would use more server resources - doing a query for each question, or doing a file read for each question? In general, are file reads more intensive than querying the database?

Amy
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 03:15 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04152 seconds
  • Memory Usage 2,253KB
  • Queries Executed 13 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_html
  • (1)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete