Click to See Complete Forum and Search --> : Query strings...
turfbult
Mar 6th, 2001, 05:47 AM
Hello,
I am having a real hard time to understand query strings!!
Currently I pass data/variables from one page to the next using hidden inputs.
This works 100%, but I'm running into some trouble with it now. What I want to do
is send an email address field from page1 to page2, so that I can then use that variable(email)
in page2, in sql statement for example.
Can someone please give me some simple example code - I'm sure I'll then be
able to figure it out.
Thanks,
T
Achichincle
Mar 6th, 2001, 07:44 AM
I'm not sure I understand completely...
You're trying to send an variable (that holds the email address) from one page to the next...
If you're using forms...
'// In page 1
<form name="whatever" action="post" method="page2.asp">
<Input Type="text" name="emailaddress" size="50">
<Input Type="submit">
</form>
'// In page 2
<html>
<p>The email you entered was: <%=Request.Form("name")%></p>
</html>
If you passed the data in a querystring (which I don't think you are in this case) you would reference the variable as:
<html>
<p>The email you entered was: <%=Request.QueryString("name")%></p>
</html>
Basically the difference is that if you pass things from a form (using POST) they are in the Request.Form collection and if you use GET (like a querystring) then they are in the Request.QueryString collection.
Hope this helps...
turfbult
Mar 6th, 2001, 07:57 AM
Maybe I didn't explain properly or what I want to do is NOT query string.
I basically want to achieve something like this forum for instance - look in the url - they send some info from one page to the next.
http://forums.vb-world.net/showthread.php?s=&threadid=59054
The email address which I want to send to the next page is not entered in a input box. I read this from my db. I suppose I now can put this email (which I just read from db) into a input/hidden input and the post it, but I am trying to learn some other stuff - "querystrings" , for now!!
Thanks,
T
Achichincle
Mar 6th, 2001, 08:13 AM
Ok. Sorry, I didn't understand what you were trying to do.
To use querystrings just call the page you want and append the querystring to it...
<html>
<p>Clicking on this link will pass the email turfbult@vbworld.com to emailprocess.asp</p>
<a href="emailprocess.asp?email=turfbult@vbworld.com">Click here</a>
</html>
Does that make sense? You basically add the key-value pairs to the url...
somepage.asp?variable1=value1&variable2=value2&variable3=value3...
You can do this in your ASP pages by doing stuff like...
<a href="process.asp?<%=variable1%>=<%=value1%>">Click here</a>
(Where variable1 and value1 are variables)
The information you pass this way will then be in the Request.QueryString collection... which means that you to get the values you:
vEmail = Request.QueryString("email")
Hopefully that's more on target than last time...
turfbult
Mar 6th, 2001, 08:47 AM
Thank you VERY much. I'm going to give it a try!!
T
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.