Solved

Read values from a GET command

Posted on 2000-02-28
6
149 Views
Last Modified: 2010-04-09
I have an HTML page which calls another using a FORM GET command. When the second one called I see the '?' and values after the URL string. How can I read those values?
0
Comment
Question by:jc31415
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
6 Comments
 
LVL 1

Expert Comment

by:zxr250
ID: 2567252
If you can use PERL, then this code will work :

#!/usr/bin/perl

#
# To handle input from forms / URL
#


#Putting the Query_string into a variable
      if ($ENV{'REQUEST_METHOD'} eq POST)
            {
            $DataLength=$ENV{'CONTENT_LENGTH'};
            read (STDIN, $QueryString, $DataLength);
            }
      else
            {
            $QueryString = $ENV{'QUERY_STRING'};
            }

#Splitting the pairs and putting them in a list
      @NameValuePairs = split (/&/, $QueryString);

#Preparing for HTML stuff

      print "Content-type: text/html","\n\n";      # MIME header

      print "<HTML>","\n";
      print "<HEAD>","\n";
      print "<TITLE>","Parameters sent in","</TITLE>","\n";
      print "</HEAD>","\n\n";
      print "<BODY>","\n\n";
#Separating the pairs and displaying them on screen.

      $n = 0;
      foreach $NameValue (@NameValuePairs)
      {
            ($Name, $Value) = split (/=/, $NameValue);
            $Value =~ tr/+/ /;
            $Value =~ s/%([\dA-Fa-f][\dA-Fa-f])/ pack ("C", hex ($1))/eg;

            print "Variable=$Name, Value=$Value <BR>\n";
            $MyVarList[$n]=$Name;
            $MyValList[$n]=$Value;
        $n++;
      }

      print "</BODY>","\n\n";
      print "</HTML>","\n\n";
0
 
LVL 3

Expert Comment

by:slok
ID: 2567256
normally, these values are sent to a CGI programs or some form of
prorgrams/scripts on the web server

you need to write some program/script (CGI) to handle it.

You can use any language to implement the CGI or handle the web
request.

It can be Perl..., TCL, Java Servlets, ASP, Cold Fusion...

hope this helps
0
 
LVL 3

Expert Comment

by:slok
ID: 2567257
normally, these values are sent to a CGI programs or some form of
prorgrams/scripts on the web server

you need to write some program/script (CGI) to handle it.

You can use any language to implement the CGI or handle the web
request.

It can be Perl..., TCL, Java Servlets, ASP, Cold Fusion...

hope this helps
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 3

Expert Comment

by:slok
ID: 2567261
sorry submitted 2 times... meant to post comment only.
0
 
LVL 8

Expert Comment

by:jbirk
ID: 2567691
If this is strictly HTML, you can grab these values with javascript.

The variable location.search contains the 'search' string in the url which is everything including and after the '?'. (excluding a hash if one is provided).

It's pretty simple.  If you need help to implement it with something specific, I can help.

-Josh
0
 
LVL 8

Accepted Solution

by:
xabi earned 50 total points
ID: 2567876
You must use this in javascript:

<script language="javascript">
<!--
var info = window.location.search.substring(1);
//-->
</script>

this will give you all the info before the ? of the URL, now you only need to split it with "&" to get the vars and split each other with "=" to get the name and the value.

xabi
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Use these top 10 tips to master the art of email signature design. Create an email signature design that will easily wow recipients, promote your brand and highlight your professionalism.
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
In this tutorial viewers will learn how to embed Flash content in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: "<!DOCTYPE html>": Use the <object> tag to embed Flash content.: To specify that the object is Flash content, d…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question