Make your own free website on Tripod.com

read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});

@array=split(/&/, $buffer);

foreach $array(@array)

{

($name,$value)=split (/=/, $array);

$FORM{$name}=$value;

}

$name=$FORM{T1};

if ($name eq ""){

& redo;

}

$date=time;

$path="/";

$id = & get_random;

print <<"EOM";

Set-Cookie: shopper=$name,path=$path,id=$id

EOM

print "Content-type: text/html\n\n";

print <<"EOM";

<html>

<head><title>Cookie test</title></head>

<body>

<p>&nbsp;&nbsp;&nbsp; </p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="cds.html">Buy CDs</a></p>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <a href="movie.html">Buy Movies</a></p>

</body>

</html>

EOM

sub update_data{

open (INPUT, ">file.$name.$id");

my ($name,$album,$number);

$name = $_[0];

$album = $_[1];

$number = $_[2];

print INPUT<<"EOM";

$album $number

EOM

close (INPUT);

}

sub get_random{

srand;

my ($number)=int (rand(10000));

return ($number);

}

sub redo{

print "Content-type: text/html\n\n";

print <<"EOM";

<html>

<head><title>Enter the Shop</title></head>

<body>

<p>&nbsp;&nbsp;&nbsp; </p>

<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Please <a href="shop.html">go back</a> and enter your name

</body>

</html>

EOM

exit

}