Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^2: How to convert an @ARGV to form based input?

by taint (Chaplain)
on Aug 21, 2012 at 08:57 UTC ( #988653=note: print w/ replies, xml ) Need Help??


in reply to Re: How to convert an @ARGV to form based input?
in thread How to convert an @ARGV to form based input?

Good advice @ig, and thank you very much for the reply.
What I actually have, is a very large script that provides every option DNS queries permit. I built, and tested it as CLI (at the console/term). Now that it all works at the term, I want to incorporate a form field where the (@ARGV) is. Since the whole thing is so large, I simply posted one of the queries as an example. I have already finished all of the web based stuff, providing each query option as a

<select> <option> </option> </select>

Then providing additional options as checkboxes, or radio.
so: the example I posted here appears as:
<select> <option>MX</option> </select>

the additional options are A, AAA, HINFO, IP6, TXT, etc...
What I do want to do, is provide an empty form input field that allows the entry of a domain name to query those options for. meaning; replace the (@ARGV) I have now, with a form input field. As it sits now (without form fielsd(s), I can query the form via:
http://mydomain.tld/dnsdig.cgi?somedomain.tld
and it returns the MX records (using the example above with the (@ARGV). But I don't want the web clients location: to see, or be able to manipulate the query string -- hence the desire to put the form fields within the script itself, and my choice of using the POST method.
I hope that helps clear things up a bit, and thanks again for your thoughtful reply.
--Chris
#!/usr/bin/perl -Tw
use perl::always;
my $perl_version = "5.12.4";
print $perl_version;


Comment on Re^2: How to convert an @ARGV to form based input?
Select or Download Code
Re^3: How to convert an @ARGV to form based input?
by Anonymous Monk on Aug 21, 2012 at 09:00 UTC

    But I don't want the web clients location: to see, or be able to manipulate the query string -- hence the desire to put the form fields within the script itself, and my choice of using the POST method.

    Yeah, POST doesn't hide anything from the client

      No?
      I've got a whois form that is accessed by way of:
      http://whois.mydomain.tld/
      and no matter what you put into the location field of your browser after the /, you'll be returned with http://whois.mydomain.tld/ in your location: bar, and an empty form, waiting for you to place a Domain name, IP address, AS number, or RP into the field. The location bar never reveals the query, and can't be manipulated.
      So I'd have to respectfully disagree with your assertion.
      --Chris
      #!/usr/bin/perl -Tw
      use perl::always;
      my $perl_version = "5.12.4";
      print $perl_version;

        The location bar never reveals the query, and can't be manipulated.

        I did not mention the location bar :) The location bar is irrelevant . The HTML can be manipulated. The HTTP can be manipulated. POST changes nothing.

        Everything that your browser sends to a web server can be manipulated. Using POST instead of GET just means it doesn't show in the location bar, which makes it slightly more difficult than simply editing the URL.

        Aaron B.
        Available for small or large Perl jobs; see my home node.

Re^3: How to convert an @ARGV to form based input?
by ig (Vicar) on Aug 21, 2012 at 14:02 UTC

    From CGI:

    It is possible for a script to receive CGI parameters in the URL as well as in the fill-out form by creating a form that POSTs to a URL containing a query string (a "?" mark followed by arguments). The param() method will always return the contents of the POSTed fill-out form, ignoring the URL's query string. To retrieve URL parameters, call the url_param() method. Use it in the same way as param(). The main difference is that it allows you to read the parameters, but not set them.

    So, you can easily ignore parameters from the URL when using CGI. If you are parsing the CGI inputs otherwise, you will have to look to the tools you are using to find out what your options are. When you are delivering the blank form, you can ignore parameters entirely, if that suits you.

    For an empty form input field, I would use something like:

    <form method="POST" action="http://mydomain.tld/dnsdig.cgi"> <input type="text" name="domain"> <input type="submit" value="Submit"> </form>

    If the user enters a URL that refers to your CGI script and includes a query string in the URL, you could detect this and issue a redirect to a URL without a query string.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://988653]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (14)
As of 2014-09-30 12:25 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (367 votes), past polls