Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Variables within a URL

Status
Not open for further replies.
Simply specify "GET" as the METHOD for your form. The browser will format the values of the form fields correctly, then put them into a query string appended to the ACTION you specified for the form.

Decoding them, and using them, is another story altogether... for that, you'll need a server-side application (Perl/CGI, ASP, PHP, ColdFusion, etc). You can decode the URL variables with JavaScript, but this will severely limit you since not all user agents have JavaScript enabled.
 
after the ?
split them (&)
u get
name=value

those are retrieve by server-side languague
here is a basic perl function to do so
link : .html?myvar=2

Code:
sub get_form {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs) {
 ($name, $value) = split(/=/, $pair);
 $value =~ tr/+/ /;
 $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
 $value =~ s/<!--(.|\n)*-->//g;
 $FORM{$name} = $value;
}

now u check the 'myvar' value like in this example

Code:
if ($FORM{myvar} == 0) {
 # do something
} else {
 # not 0 do other
}
[/code}

or u can use cookies to pass value too
read thread216-266938 [img]http://205.205.212.44/img/wmail.jpg[/img]

someone knowledge ends where
someone else knowledge starts
 
ack! complicated language. if you use asp they all asume thier variable names automaticly. all you have to do is use them. for example, a page like this:

page.asp?var1=value1&var2=value2

those variables could be recived like this:
Code:
hey everyone, var1 equals <%=var1%> and var2 equals <%=var2%>!
much easyer X-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top