hor
asked on
Using VB5-Cgi Objects to pass variables to webpage
I'm using VB5-CGI Objects to write cgi and Access 97 to
keep my data. I have a webpage which displays the result after querying the
database. The result will have a hyperlink to another webpage. I want to pass the
result to the final webpage. So, I use HTML.bodyHTML to write like this...
<a href="http://default/sample.htm?Data1=" & rs.Fields("Data1") & "&Data2=" &
rs.Fields("Data2") & "&Data3=" & rs.Fields("Data3") target="blank"> "
But the final webpage can only get the value of Data1, it can't get the others. If my
Data1 has the value of "My data", the final webpage gets only 'My', but no 'data'.
So, how should I pass variables using VB5-CGI Objects? Please help...
Thanks in advance...
keep my data. I have a webpage which displays the result after querying the
database. The result will have a hyperlink to another webpage. I want to pass the
result to the final webpage. So, I use HTML.bodyHTML to write like this...
<a href="http://default/sample.htm?Data1=" & rs.Fields("Data1") & "&Data2=" &
rs.Fields("Data2") & "&Data3=" & rs.Fields("Data3") target="blank"> "
But the final webpage can only get the value of Data1, it can't get the others. If my
Data1 has the value of "My data", the final webpage gets only 'My', but no 'data'.
So, how should I pass variables using VB5-CGI Objects? Please help...
Thanks in advance...
The problem you are suffering is that you are putting invalid characters into the url. In your example the space between 'My' and 'data' needs to be converted to a '+'.
Ths is known as URL Encoding which means that any character after the question mark that is not valid within a URL is encoded as a + if it is a space or its ASCII value in Hex preceded by a %.
VB is not the easiest language to do this in but fortunately the server object has a URLEncode method that will do the job for us so your code should be changed to the following.
<a href="http://default/sample.htm?Data1=" & Server.URLEncode(rs.Fields ("Data1")) & "&Data2=" &
Server.URLEncode(rs.Fields ("Data2")) & "&Data3=" & Server.URLEncode(rs.Fields ("Data3")) target="blank"> "
Hope this helps
Steve
Ths is known as URL Encoding which means that any character after the question mark that is not valid within a URL is encoded as a + if it is a space or its ASCII value in Hex preceded by a %.
VB is not the easiest language to do this in but fortunately the server object has a URLEncode method that will do the job for us so your code should be changed to the following.
<a href="http://default/sample.htm?Data1=" & Server.URLEncode(rs.Fields
Server.URLEncode(rs.Fields
Hope this helps
Steve
ASKER
What references or components should I use so that the Server.URLEncode() will be accepted by VB5 when I press F5?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER