68 lines
1.3 KiB
Perl
68 lines
1.3 KiB
Perl
|
use IO::Socket;
|
||
|
|
||
|
$name = 'Tom';
|
||
|
$email = 'a@a.com';
|
||
|
|
||
|
$string = '?' . "name=" . $name . "&" . "email=" . $email;
|
||
|
$string =~ tr/ /+/;
|
||
|
|
||
|
$socket = IO::Socket::INET->new
|
||
|
(
|
||
|
Proto => "tcp",
|
||
|
PeerAddr => "yourserver.com",
|
||
|
PeerPort => 80,
|
||
|
);
|
||
|
|
||
|
$socket->autoflush(1);
|
||
|
|
||
|
print $socket "GET /reg.cgi$string ', 'HTTP/1.0\015\012\015\012";
|
||
|
|
||
|
while ($line = <$socket>) {
|
||
|
$results .= $line
|
||
|
}
|
||
|
|
||
|
close $socket;
|
||
|
print $results;
|
||
|
if ($results =~ /Thanks for registering./mg) {
|
||
|
|
||
|
print "Success."
|
||
|
|
||
|
} else {
|
||
|
|
||
|
print "Sorry, there was an error."
|
||
|
|
||
|
}
|
||
|
|
||
|
#File: reg.cgi
|
||
|
|
||
|
|
||
|
#!/usr/local/bin/perl
|
||
|
|
||
|
use CGI;
|
||
|
|
||
|
$co = new CGI;
|
||
|
|
||
|
print $co->header,
|
||
|
|
||
|
$co->start_html(
|
||
|
-title=>'CGI Example',
|
||
|
-author=>'yourName',
|
||
|
-meta=>{'keywords'=>'CGI Perl'},
|
||
|
-BGCOLOR=>'white',
|
||
|
-LINK=>'red'
|
||
|
);
|
||
|
|
||
|
if ($co->param()) {
|
||
|
$! = 0;
|
||
|
open FILEHANDLE, ">>reg.log";
|
||
|
print FILEHANDLE "Date: " . `date`;
|
||
|
print FILEHANDLE "Name: " . $co->param('name') . "\n";
|
||
|
print FILEHANDLE "email: " . $co->param('email') . "\n";
|
||
|
close FILEHANDLE;
|
||
|
unless ($!) {
|
||
|
print "Success.";
|
||
|
} else {
|
||
|
print "Sorry, there was an error: $!";
|
||
|
}
|
||
|
}
|
||
|
print $co->end_html;
|