CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Need a Custom or Prewritten Perl Program?: I need a program that...:
a petition script

 



cailet
Deleted

May 31, 2000, 11:07 PM

Post #1 of 3 (2559 views)
a petition script Can't Post

I need a script that will allow a user to only enter their name and will then write it to a page under the previous name.

thanks


Prometheus
Deleted

Jun 3, 2000, 6:22 PM

Post #2 of 3 (2559 views)
Re: a petition script [In reply to] Can't Post

Hello,

Not sure if I totally follow you here,, But I can do this for you for a small fee or give you the jist and then you can do it.

thanks,
james


Cretep
User

Jun 3, 2000, 8:03 PM

Post #3 of 3 (2559 views)
Re: a petition script [In reply to] Can't Post

Hi
This should do the trick. This has only taken me fifteen minutes or so and has been tested. I am more that happy to modify it to further suit your needs. If you have any problems setting it up just post the problem to this forum or to my email address.

#!/usr/bin/perl

# Change the above path to suite your server

# Petition script. Free to use by any one. No credit needed and absolutely no copyright imposed!!
# by Peter Crouch
# Email: woodduck@bigpond.com
# URL: http://www.perlbay.com

$database = "names.txt"; # The names are stored here
$script_name = "petition.cgi"; # The name of the script

&phrase_input;
&action;
end;

sub phrase_input {
read(STDIN, $input, $ENV{'CONTENT_LENGTH'});

@pairs = split(/&/, $input);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);

$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$FORM{$name} = $value;
}
}

sub action{
if ($FORM{'action'} eq "add"){
&add;
}else {
&form;
}
}

sub form {
# You can modify any of the HTML in here however leave the form alone
print "Content-type: text/html\n\n";

print qq~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Please sign our petition</title>
</head>

<body body="#ffffff" text="#000000" link="#0000ff" alink="#ff0000" vlink="#0000ff">
<font face="verdana" size="-1">Please sign our petition.</font>
<form action="$script_name" method="post">
<input name="action" type="hidden" value="add">
<table>
<tr>
<td><font face="verdana" size="-1">Your Name:</font></td>
<td><input name="name" type="text" value=""></td>
</tr><tr>
<td colspan="2" align="center"><input type="submit" value="Submit"></td>
</tr>
</table>

</form>

</body>
</html>
~;
}

sub add {
open (ADD,">>$database") | | die "Error opening the database -\n $!\n";
flock ADD, 2;
print ADD "$FORM{'name'}\n";
flock ADD, 8;
close(ADD);
&response;
}

sub response {
print "Content-type: text/html\n\n";
# You can modify any of the HTML in here.
print qq~
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<html>
<head>
<title>Thank you for signing our petition</title>
</head>

<body body="#ffffff" text="#000000" link="#0000ff" alink="#ff0000" vlink="#0000ff">
<font face="verdana" size="3">Your name has been added to our petition. Thank you.</font>
</body>
</html>
~;
}

Good luck

Peter Crouch

[This message has been edited by Cretep (edited 06-03-2000).]

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives