Solved

Read values from a GET command

Posted on 2000-02-28
6
148 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
Technology Partners: 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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

Suggested Solutions

This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
Find out what you should include to make the best professional email signature for your organization.
In this tutorial viewers will learn how add a scalable full-width header using CSS3. Create a new HTML document with an internal stylesheet. Set a tiled background.:  Create a new div and name it Header. Position it with position:absolute at the top…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

739 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