Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Simple info gathering form

mercutio98ukmercutio98uk Posts: 3Member
I need a .pl script to gather a single item from a html page that uses a POST method:


Username:



I need the perl script that reads this info to save it formated/unformated however to a local harddisk.
192.168.0.228 is my IIS webserver. I know this should be amazingly simple but I cant get any further than getting the data on screen in a HTML page generated by readpost.pl can anyone help please?

Comments

  • medina_raptormedina_raptor Posts: 6Member
    hi

    try the CGI module, is so easy :)
    (use CGI)

    Carlos

    : I need a .pl script to gather a single item from a html page that uses a POST method:
    :
    :


    : Username:
    :
    :
    :
    : I need the perl script that reads this info to save it formated/unformated however to a local harddisk.
    : 192.168.0.228 is my IIS webserver. I know this should be amazingly simple but I cant get any further than getting the data on screen in a HTML page generated by readpost.pl can anyone help please?
    :
    :



  • mercutio98ukmercutio98uk Posts: 3Member
    Ive been trying to hack together some CGI/Perl and teaching myself a little as I go along but ive litterally had no experience with it before. Not sure what you mean by CGI module? And yes I have tried looking in books etc and I can get the data to be displayed as HTML after I hit submit but to get it to file is getting very confusing. It might be that the examples ive been following dont lend themselves too well to saving to disk, not sure.

    : hi
    :
    : try the CGI module, is so easy :)
    : (use CGI)
    :
    : Carlos
    :
    : : I need a .pl script to gather a single item from a html page that uses a POST method:
    : :
    : :


    : : Username:
    : :
    : :
    : :
    : : I need the perl script that reads this info to save it formated/unformated however to a local harddisk.
    : : 192.168.0.228 is my IIS webserver. I know this should be amazingly simple but I cant get any further than getting the data on screen in a HTML page generated by readpost.pl can anyone help please?
    : :
    : :
    :
    :
    :
    :

  • medina_raptormedina_raptor Posts: 6Member
    in your ".pl" file include this, you should change the extension of the file to ".cgi"

    #!/usr/bin/perl
    use CGI;
    $query = new CGI;
    $user = $query->param('username');
    #now you can play with the variable $user, it has the information that you did type on the html

    Carlos

    : Ive been trying to hack together some CGI/Perl and teaching myself a little as I go along but ive litterally had no experience with it before. Not sure what you mean by CGI module? And yes I have tried looking in books etc and I can get the data to be displayed as HTML after I hit submit but to get it to file is getting very confusing. It might be that the examples ive been following dont lend themselves too well to saving to disk, not sure.
    :
    : : hi
    : :
    : : try the CGI module, is so easy :)
    : : (use CGI)
    : :
    : : Carlos
    : :
    : : : I need a .pl script to gather a single item from a html page that uses a POST method:
    : : :
    : : :


    : : : Username:
    : : :
    : : :
    : : :
    : : : I need the perl script that reads this info to save it formated/unformated however to a local harddisk.
    : : : 192.168.0.228 is my IIS webserver. I know this should be amazingly simple but I cant get any further than getting the data on screen in a HTML page generated by readpost.pl can anyone help please?
    : : :
    : : :
    : :
    : :
    : :
    : :
    :
    :



  • sifukurtsifukurt Posts: 1Member
    : in your ".pl" file include this, you should change the extension of the file to ".cgi"
    :
    : #!/usr/bin/perl
    : use CGI;
    : $query = new CGI;
    : $user = $query->param('username');
    : #now you can play with the variable $user, it has the information that you did type on the html

    In addition to using CGI to create a lot of the HTML for you, and in addition to doing the above, you can also use CGI to return a list of all of the various parameters passed. For example:

    -----START CODE-----
    #!/usr/bin/perl

    use CGI qw/standard/;
    use strict;
    use vars qw/ $query $param @params /;

    print header;
    # Note the above line is part of CGI, and not
    # a built-in perl function

    $query = new CGI;
    @params = $query->param;
    foreach $param ( @params ) {
    print ("$param: " . $query->param($param) . "

    ");
    }
    -----END CODE-----

    This is *really* handy for when you want to say "Ok, show me absolutely everything that is being passed from the form to the CGI script." The CGI module is one of those things that will save you many, many hours in the long run.
  • heeroyuyheeroyuy Posts: 125Member
    You mentioned you needed to write to a file as well. From your previous post I couldn't tell if you knew how to do that or not, so here it is, hope it helps =)
    [code]
    open("handle",">>filename");
    print handle "INSERT AN ARRAY OR STRING CONTAINING EVERYTHING U NEED HERE";
    close(handle)
    [/code]
    there is a very basic code for appending to a file, if you want to overwrite the contents of the file then simply change the >> in the second parameter to >

    --Heero Yuy
  • mercutio98ukmercutio98uk Posts: 3Member
    Thanx guys, with all the above (or below as it were) got it sorted now, cheers for all the support.


    : You mentioned you needed to write to a file as well. From your previous post I couldn't tell if you knew how to do that or not, so here it is, hope it helps =)
    : [code]
    : open("handle",">>filename");
    : print handle "INSERT AN ARRAY OR STRING CONTAINING EVERYTHING U NEED HERE";
    : close(handle)
    : [/code]
    : there is a very basic code for appending to a file, if you want to overwrite the contents of the file then simply change the >> in the second parameter to >
    :
    : --Heero Yuy
    :

Sign In or Register to comment.