Click to See Complete Forum and Search --> : passing variables?
CrazyGaz
06-19-2003, 06:00 PM
I can pass variables from a form to a page and by using request.querystring but how do I pass a variable across multiple pages I would assume if I used queryString then someone could manually type in the address and then they wouldn't have to register.
help appreciated, Gaz
khaki
06-19-2003, 06:31 PM
hi Gaz...
you could just keep passing the variables by tucking them into hidden text boxes on page after page.
the user can't alter it that way...
the variables will always be available...
and it's not too big of a deal to do it.
(and i'm not sure that there is a more reliable way to do it, actually)
d'ya think that might work out for you?
;) k
PeOfEo
06-20-2003, 12:32 AM
But if you do the hidden text box you are going to be combining a few different pages code into one and its going to refresh the page with new text boxes at the push of a button of you can invision that but you can just redirect them to a url and have it be like go to this page lets say ./end.asp? + the text box data or whatever here when he clicks a command button. See what I am saying. Use that method to form your query string. The tuck that data right back into a hidden text box or something before he goes on to the next page and form it again the same way.
khaki
06-20-2003, 08:37 AM
i have to assume that Peo is joking...
so I will not even respond to the hilariously inaccurate claims that he makes...
but if you want a QueryString solution Gaz... just let me know (although I assumed that you did not... since you mentioned that you were concerned that the user could alter it).
a form is the most secure way of the 2.
(not to mention that is it also the more basic and simple of the 2)
if you need more help or advice with this... just let me know.
;) k
PeOfEo
06-20-2003, 03:25 PM
I dont know asp classic yet. So sue me but can I assume that you will be using about the same method on any semi object based server side language. I just think it can be a real stess on the server if he has a menu and about 8 pages he can go to from there and he needs to pass a variable to each. Do you see what I am saying. Loading all of that data and dealing with all of that code will be a burdon on the server so a query string would be a more painless way to do it.
khaki
06-20-2003, 03:49 PM
even if it's like 10 variables a page (or even more)...
the server can handle form submissions with it's eyes closed.
I don't see form submission (and variable collection) as a major strain (since it's not like the server is being asked to keep SessionVariables in memory or anything)
that's all I'm saying.
Here is a good link which I just referenced in another thread (same subject, actually)
http://www.4guysfromrolla.com/webtech/faq/Advanced/faq4.shtml
it links to this page as well...
http://www.4guysfromrolla.com/webtech/092098-2.shtml
so you see...
there are many ways to skin a cat (I offered mine... which I prefer over the others)
it's all a matter of choice, I guess :rolleyes:
(as long as it gets the job done :) )
;) k
PeOfEo
06-20-2003, 03:55 PM
well If it is a login form submission and you have to keep data about the user through a seriese of pages that would strain the server plus would you really want to lump all that code together as one file? I mean that would be a pain and if something goes wrong the whole thing is dead and you are trying to find an error in it and its a mile of code.
khaki
06-20-2003, 04:03 PM
it's not "miles of code"...
it's just stuff like this:
<%
response.write("<form name='page1'>")
response.write("<input type='hidden' name='answ1' value=" & answer1 & ">")
response.write("<input type='hidden' name='answ2' value=" & answer2 & ">")
response.write("<input type='hidden' name='tot1' value=" & total1 & ">")
response.write("</form>")
%>
...which populates hidden text boxes with values passed from a form on the previous page.
There are 3 values in the above example.
Even if there were 80... it's nothing for the server to handle that.
There is no need to "combine" every line of code from each page...
all you need to do is collect and pass the values that you need as you go along.
and if "something goes wrong"...
there is NO method that can save everything anyway (aside from a database... which would definitely be a strain on the server in this case anyway).
once again.... my opinion...
;) k
CrazyGaz
06-20-2003, 04:04 PM
Cheers khaki...however the only way I can get it to work is with a submit button which isn't exactly what I want, is there a way to submit without a submit button?
khaki
06-20-2003, 04:09 PM
hi Gaz...
pretty much any event handler can submit the form for you.
how would you prefer to do it?
;) k
CrazyGaz
06-20-2003, 04:11 PM
<a href="page2.asp"> that would be the HTML link
<%
response.write("<form name='page1'>")
response.write("<input type='hidden' name='username2' value=" & RS("username") & ">")
response.write("</form>")
%>
that would be the form.
so when I click the link I just go to the "page2.asp" and it doesn't request it.
page2.asp has the following ASP
<% username=Request.form(username2)
response.write "hello " & username %>
thanks, Gaz
khaki
06-20-2003, 04:22 PM
okay Gaz....
we can work with that...
but listen...
I just got a carload of weekend beach visitors that have just invaded the house...
and I gotta get them over to happy hour before they drive me crazy :)
I'll pop back on the computer in about another hour or so and work-up something for you to use (I'm not drinking today... so my code will be safe to drive :) lol)
see you in a bit...
;) k
PeOfEo
06-20-2003, 04:37 PM
Drunk codeing lol thats a laugh you ever done it? What about if you smoke a little mj? I dont do it myself but what would it be like to do some webdesign while your high?
Ribeyed
06-20-2003, 04:43 PM
funny that i do my best coding stoned!;)
khaki
06-20-2003, 06:37 PM
Originally posted by [SWR]Ribeyed
funny that i do my best coding stoned!;) and by that...
I'm sure that he doesn't mean what it sounds like he means
(so let's not jump to any conclusions :) )
But ummm...
:)
y'know ;)
so anyhow....
I drove my friends to happy hour...
I did have a margarita (okay... 2)...
but my bf drove me, Bob Marley, and Mary Jane back to the house, and I'm gonna whip-up some dinner before the rest of the loud crowd returns...
so....
I don't really have time to code this yet for Gaz
(and if the rumour I hear is true... I may be driving to Key West on Sunday :) for my birthday :) ... so I may not get around to it for a few days.. or a week... I think :) )
So Dave (or Peo) will need to pick-up the slack.
Well... back to the chronic kitchen (I'm suddenly very hungry ;) )...
later yo....
;) k