
Killian
Deleted
May 8, 2001, 9:47 PM
Post #12 of 14
(1278 views)
|
I'm trying to set up a signup form that will let people create their own "accounts" by making a text file for each person(is this called a flatfile database?) and storing the info they gave in the text file, one line per form field. I'm going to be using this in my online game if i can get it working, of course I will try to make the code better if possable, and is flatfile a good way to do an online game database or should i use something else? here is the code, the current signup form I'm using consists of just username and password, although when i get it working and i get my game set up, I will obviously add more things. #!/usr/bin/perl -w print "Content-type:text/html\n\n"; if ($ENV{'REQUEST_METHOD'} eq "GET") { $in = $ENV{'QUERY_STRING'}; } else { $in = <STDIN>; } print "<html><head><title>Online Game</title> <STYLE type\=text/css> tbody \{font\: 8pt Verdana\; color\: dddddd\;\} body \{font\: 8pt Verdana\; color\: dddddd\;\} td \{font\: 8pt Verdana\; color\: dddddd\;\} tr \{font\: 8pt Verdana\; color\: dddddd\;\} p \{font\: 8pt Verdana\; color\: dddddd\;\} A \{text\-decoration\: none\; COLOR\: bbbbbb\;\} A\:hover \{text\-decoration\: underline\; color\: ccccccc\;\} </STYLE> </head>"; print "<body bgcolor=000000 text=dddddd>"; @values = split(/&/, $in); foreach $data (@values) { ($name, $value) = split(/=/, $data); $value =~ s/%(..)/pack("c",hex($1))/ge; $value =~ s/\+/ /g; $signup_info{$name} = $value; } if (-e "user_data/$signup_info{username}.txt") { print "I'm sorry but someone has already chosen that username."; } else { open (FILE, ">user_data/$signup_info{username}.txt") or die "Error creating file - $!\n"; print FILE "$signup_info{username}\n"; print FILE "$signup_info{password}\n"; close (FILE); print "you have signed up."; } print "</body></html>"; That's my code. every time i type in a username/password into my page it just comes up blank, no text at all. Also, the script is in folder cgi-bin and there is a user_data folder in there where the users txt files go, the host I'm using lets you use cgi script anywhere, if that is of any help.
|