Solved

Read values from a GET command

Posted on 2000-02-28
6
141 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
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction The Google Maps API offers various ways to draw dynamic and static maps.  Using a combination of PHP and JavaScript, you can draw active JavaScript maps that allow pan-and-zoom in the client browser window.  You can also draw "static" …
Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to style a corner ribbon overlay for an image using CSS Create a new class by typing ".Ribbon":  Define the class' "display:" as "inline-block": Define its "position:" as "relative": Define its "overflow:" as …

758 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now