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: Perl Programming Help: Beginner:
Creating a html page from form input

 



ad65
Deleted

May 14, 2001, 7:27 AM

Post #1 of 3 (667 views)
Creating a html page from form input Can't Post

I need to be able to create a html page from what someone types in a form field. The part:

open (ALPHA, ">$FORM{name}.html")

doesn't seem to work, if i put

open (ALPHA, ">newname.html")

it creates a html page called newname.html, but i want it to create the name from the form input. Is there any way to do this?

# The following accepts the data from the form

if ($ENV{'REQUEST_METHOD'} eq 'POST') {

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

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

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

$FORM{$name} = $value;
}

# The following creates the file

open (ALPHA, ">$FORM{name}.html") || die "Error creating file. $!\n";

print ALPHA "Name: $FORM{name}\n";
print ALPHA "By: $FORM{user}\n";
print ALPHA "Cheat: $FORM{cheats}\n";

&thank_you;
}



randor
User

May 14, 2001, 1:36 PM

Post #2 of 3 (657 views)
Re: Creating a html page from form input [In reply to] Can't Post

this is just a guess, but try this:

open (ALPHA, ">$FORM{'name'}.html")
instead of this:
open (ALPHA, ">$FORM{name}.html")

hope this works




AICapone
Deleted

May 14, 2001, 6:12 PM

Post #3 of 3 (650 views)
Re: Creating a html page from form input [In reply to] Can't Post

oh oh oh..why don't you use cgi.pm?? anyway, thats how I would've done that:

###############################
#!/usr/bin/perl

use CGI qw(param);

$name=param("name");
$cheat=param("cheat");
$user=param("user");

open (ALPHA, ">$name.html")
&thank_you;
}
###############################

yet I wouldn't do it myself. I mean, to leat somebody name files for you?? and what if they'll make somehting like "oh isn't that a really really really, i mean really nice name for my new file???" ?. Don't forget to put filtration and restriction on file names

Rest in Peace,
AlCapone


 
 


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

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