Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Good morning monks:
I am having problems setting a cookie Can anyone look at my code and help me out?
#one.pl #!/usr/bin/perl use strict; use CGI; my $cgi = new CGI; print $cgi->header; print $cgi->start_html('A Simple Example'), $cgi->h1('A Simple Example'), $cgi->start_form(-action=>"test.pl"), "What's your name? ",$cgi->textfield('name'), $cgi->p, $cgi->submit, $cgi->end_form, $cgi->end_html;


#test.pl #!/usr/bin/perl use strict; use CGI::Cookie; use CGI; my $cgi = new CGI; print $cgi->header( -cookie => new CGI::Cookie(-name => 'name', -value=> $cgi->param( +'name'), -expires => 'Thu, 26- +Sep-2002 00:00:00 GMT', -domain => 'students. +cs.byu.edu' ) ). $cgi->start_html(-title => 'A Simple Example', -bgcolor => $cgi->param('color')); if ($cgi->param()) { print $cgi->center( $cgi->h3("Hello: ". $cgi->param('name'))); } print $cgi->start_form(-action => "results.pl"), "What's your name? ",$cgi->textfield('name'), $cgi->p, "What's the combination?", $cgi->p, $cgi->checkbox_group(-name=>'words', -values=>['eenie','meenie','minie','moe'], -defaults=>['eenie','minie']), $cgi->p, "What's your favorite color? ", $cgi->popup_menu(-name=>'color', -values=>['red','green','blue','chartreuse']), $cgi->p, $cgi->submit('SUBMIT'), $cgi->end_form, $cgi->end_html(); exit(0);

#!/usr/bin/perl # results.pl use strict; use CGI::Cookie; use CGI; my $cgi = new CGI; print $cgi->start_html(-title => 'Results', -bgcolor => $cgi->param('color')); if ($cgi->param()) { print $cgi->center( $cgi->h3("Hello: ". $cgi->param('name')), $cgi->p, "The keywords are: ",join(", ",$cgi->param('words')), $cgi->p, "Your favorite color is: ",$cgi->param('color')); } print $cgi->end_html(); exit(0);

-thanks

In reply to I am having problems setting a Cookie by chuleto1

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

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

    No recent polls found