Doppelganger data

 
Gadgets

Authentication
Crypto
ENV
HTTP
Regex
Regex 2
Robots
Snarfs
SSL
Stepper

Anyone who's ever run a Web site has seen this: duplicate sets of data from a form. Sometimes three, four sets. Are users really filling out and sending in reports two, three, four times?

Of course not. They're banging away at the form's "Submit" button while a stubborn CGI script taps its finger and clears its throat. What makes them think clicking twice will speed things up?

At any rate, it's easy enough to prove that this is what's happening. Set up a simple script that time-stamps the data and writes it to a file.

#!/usr/bin/perl

use CGI;
my $query = new CGI;
print $query->header;
$name = $query->param('name');
$game = $query->param('game');
$number = $query->param('number');

$date = localtime(time());

open(DATA, ">>/usr/temp/data") || die "Can't open data file";
print DATA "$date\t$name\t$game\t$number\n";
close DATA;

print <<EOT;
<html>
<head>
<title>Thanks</title>
</head>
<body>
<h1 align=center>Thanks!</h1>

$date<br>
Name: $name<br>
Game: $game<br>
Number: $number<br>

</body>
</html>

EOT

Now, an HTML form that posts to our script.

<html>
<head>
<title>Do Stuff</title>
</head>

<body>
<form action="/cgi-bin/getstuff.cgi" method="POST">
<input type="hidden" name="name" value="John">
<input type="hidden" name="game" value="crypto">
<input type="hidden" name="number" value="4"><br>
<br>
<input type="submit" value="Submit">
</form>

</body>
</html>


  Next >>






Home | Gadgets | Code | Links | Reads | Contact

Copyright © 1999, 2001, 2002 by John H. Byrd
All rights reserved.