Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Help... I know nothing about perl...

by astanley (Beadle)
on May 01, 2001 at 21:12 UTC ( [id://77033]=note: print w/replies, xml ) Need Help??


in reply to Help... I know nothing about perl...

I recommend using CGI.pm, and I think most people on this site will agree. A typical response page would look like this:
#!/usr/bin/perl use CGI qw(:standard); use strict; my $cgi = CGI->new; print $cgi->header; if ($cgi->param("name") ne "") { print "Welcome " . $cgi->param("name" +) }

The HTML form to invoke this would be:
<form method=post action=yourscript.pl> <input type=text name=name> <input type=submit name=submit> </form>

Hope that clears it up a bit for you

-Adam Stanley
Nethosters, Inc.

Replies are listed 'Best First'.
Re: Re: Help... I know nothing about perl...
by Eureka_sg (Monk) on May 01, 2001 at 21:24 UTC

    When you are using CGI in OO form,you should use CGI; and not use CGI qw(:standard);.

    I recommend that you just import the functions in and use them

    #!/usr/bin/perl use CGI qw(:standard); use strict; my $name = param('name'); print header(); if ($name) { print "Welcome " . $name }
      Thanks, OK, so do I place the function in my current form handeler? (I am embarrassed that I am asking for help and do not even know where to start).

        No, it replaces your current form handler. Of course you'll need to expand it to output more of a document.

        #!/usr/bin/perl use CGI; my $q = new CGI; print $q->header; # HTTP header # Note: the $name and 'name' equivalence is arbitrary. my $name = $q->param('name') || "Anonymous"; print <<ENDOFPAGE; <html><head><title>Thank you, $name!</title></head><body> <p>$name, I want to personally thank you for making world peace possible!</p> <p>$name, if you print this page, and glue it onto your forehead, you'll never need to pay for anything again! You'll even get a free shirt with long sleeves and a ride to a big building where they'll put you in a comfy room with padded walls!</p> </body></html> ENDOFPAGE # That ENDOFPAGE must be on its own line!

Re: Help... I know nothing about perl...
by Roninpc (Initiate) on May 01, 2001 at 21:23 UTC
    Ok, I see how it works, but I (sorry, I really am out of my league here) don't know if I add that script to my current for handeler, or save it as a separate function. Do I call it from the first?

    I am going to take look at the suggested links to see if they show how it is done. Currently, the form handeler gets the data from get.html, and emails it back using a page called get.txt. My client wants me to change his form so that instead of a successful submission going to a generic "thanks" page, that it says "Thanks Adam, here is your certificate for $25 bucks off. Please print this page."

    While I can use javascript for the "print this page" part, and I see how your suggestion works, but I don't know what to do with it... I was hoping to find a complete for that does the same thing on this (or any of the free cgi script sites) to learn how, but I cannot seem to find the cgi you wrote above in use. Thanks for your reply.

      The webmonkey site I mention below should help clear these questions up. Basicly, the action property of your form needs to point to the cgi script that handles the request. Your cgi script needs to be in a directory on the webserver that allows cgi to execute (often '/cgi-bin').

      astanley's script should work for you with very minor modification.


      TGI says moo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (3)
As of 2024-04-23 23:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found