Welcome to Dream.In.Code
Getting Help is Easy!

Join 136,331 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 2,835 people online right now. Registration is fast and FREE... Join Now!




Cookie script not working

 
Reply to this topicStart new topic

Cookie script not working

perluser
2 Sep, 2008 - 11:35 PM
Post #1

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 8

I'm trying to store cookies but its not working with the code I have. Do anyone see any errors?

<!c11ex4.html>
<HTML>
<HEAD><TITLE>Maribeth Designs</TITLE></HEAD>
<BODY>
<H1>Select a Background Color</H1>
<FORM ACTION="http://servername.netfirms.com/cgi-bin/c11/c11ex4a.cgi" METHOD=GET>
<P>
<INPUT TYPE=radio NAME=Color VALUE=hotpink>Pink<BR>
<INPUT TYPE=radio NAME=Color VALUE=silver>Silver<BR>
<INPUT TYPE=radio NAME=Color VALUE=tan>Tan<BR>
<INPUT TYPE=radio NAME=Color VALUE=white>White<BR>
</P>
<INPUT TYPE=submit VALUE="Color Choice">
</FORM></BODY></HTML>
---------------------
#!/user/bin/perl
#c11ex4a.cgi - first script
use CGI qw(:standard);
#prevent Perl from creating undeclared variables
use strict;
#declare and assign value to variable
my ($color, $C_color);
$color = cookie('Color');
#create and send cookie
$C_color = cookie(-name => "Color",
-value => "$color";
-path => "/cgi-bin/c11");
print header(-cookie => $C_color);
#create Web page
print "<HTML>\n";
print "<HEAD><TITLE>Maribeth Designs</TITLE></HEAD>\n";
print "<BODY BGCOLOR=$color>\n";
print "<HR>\n";
print "<FORM ACTION='http://servername.netfirms.com/cgi-bin/c11/c11ex4b.cgi' METHOD=POST>\n";
print "<H1>Maribeth Designs</H1>\n";
print "<I>Welcome to our Web site!</I><BR><BR><BR>\n";
print "<INPUT TYPE=submit VALUE='Go to Next Page'>\n";
print "</FORM>\n";
print "</BODY></HTML>\n";
---------------------
#!/user/bin/perl
#c11ex4b.cgi - second script
print "Content-type: text/html\n\n";
use CGI qw(:standard);
#prevent Perl from creating undeclared variables
use strict;
#declare variable
my $color;
#assign value to variable and retrieve Color cookie
$color = cookie('Color');
#create Web page
print "<HTML>\n";
print "<HEAD><TITLE>Maribeth Designs</TITLE></HEAD>\n";
print "<BODY BGCOLOR=$color>\n";
print "<HR>";
print "<H1>Maribeth Designs</H1>\n";
print "<I>Thank you for visiting our Web site!</I>\n";
print "</BODY></HTML>\n";
User is offlineProfile CardPM
+Quote Post

perluser
RE: Cookie Script Not Working
3 Sep, 2008 - 11:46 AM
Post #2

New D.I.C Head
*

Joined: 6 Aug, 2008
Posts: 8

Solved!
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 12/2/08 07:52AM

Live Help!

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month