Gossamer Forum
Home : General : Perl Programming :

Re: Script what shows an image and records data?

Quote Reply
Re: Script what shows an image and records data? In reply to
Do you mean like:

#!/usr/bin/perl

use CGI qw(:standard);

&main();

sub main {

my $IN = new CGI;

my $username = $IN->param('username');
my $image = $IN->param('image');
my $url = "http://www.domain.com";
my $file = "/path/to/datafile.txt";

if (($username =~ /^\w+$/) && ($image =~ /\.(gif|jpg)$/)) {

open(FILE,">>$file") || die &error("Couldn't open file : $!");
print FILE "$username|$image";
close FILE;

print "Location: $url/$image\n\n":

} else {

&error("Invalid query string.");

}

}


sub error {

my ($msg) = shift;

print header;

print $msg;

exit();

}



I'm not sure if that is what you mean so correct me if I missed the point.
You can easily change it to work with a form if that is how the data is being passed to the script.

You would use it like:

http://www.domain.com/cgi-bin/script.cgi?username=bob&image=grafic.gif



Paul
Installations:http://wiredon.net/gt/
Support: http://wiredon.net/forum/

Subject Author Views Date
Thread Script what shows an image and records data? Chef 2561 May 25, 2001, 1:08 AM
Thread Re: Script what shows an image and records data?
Paul 2482 May 25, 2001, 2:47 AM
Post Re: Script what shows an image and records data?
Chef 2454 May 25, 2001, 3:23 AM
Thread Re: Script what shows an image and records data?
Chef 2469 May 25, 2001, 3:25 AM
Post Re: Script what shows an image and records data?
Paul 2504 May 25, 2001, 3:33 AM