help - im new to perl and ive downloaded a simple perl script that im trying to run on my computer -i use the updated version of indigo perl on win98 -listed below are the html and scripts -can someone tell me where i am going wrong note: if i add line open(OUTF,">>/cgi-bin/survey.out") then no survey.out file is created (i just get the "Couldn't open for writing!" if i leave the /cgi-bin/ out of the script then i get a netscape error msg that says "document contains no info - try again later" then a file called survey.out is created in my cgi-bin however, no data is written in it your help in the matter is appreciated thanks Danny __________________________________________________ Do You Yahoo!? Make international calls for as low as $.04/minute with Yahoo! Messenger http://phonecard.yahoo.com/
#!perl print "Content-type:text/html\n\n"; 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; $value =~ s/\n/ /g; # replace newlines with spaces $value =~ s/\r//g; # remove hard returns $value =~ s/\cM//g; # delete ^M's $FORM{$name} = $value; } open(OUTF,">>/cgi-bin/survey.out") or dienice("Couldn't open survey.out for writing: $!"); # This locks the file so no other CGI can write to it at the # same time... flock(OUTF,2); # Reset the file pointer to the end of the file, in case # someone wrote to it while we waited for the lock... seek(OUTF,0,2); print OUTF "$FORM{'name'}|$FORM{'email'}|"; print OUTF "$FORM{'howreach'}|$FORM{'rating'}|"; %boxes = ( "des" => "Website Design", "svr" => "Web Server Administration", "com" => "Electronic Commerce", "mkt" => "Web Marketing/Advertising", "edu" => "Web-Related Education" ); foreach $key (keys %boxes) { if ($FORM{$key} == 1) { print OUTF "$key,"; } } print OUTF "|$FORM{'comments'}\n"; close(OUTF); print <<EndHTML; <html><head><title>Thank You</title></head> <body> <h2>Thank You!</h2> Thank you for your feedback.<p> <a href="index.html">Return to our home page</a><p> </body></html> EndHTML sub dienice { my($msg) = @_; print "<h2>Error</h2>\n"; print $msg; exit; }
<html><head><title>Survey</title></head> <body> <h2>Survey</h2> <form action="/cgi-bin/survey.cgi" method="POST"> Enter your name: <input type="text" name="name" size=30><p> Your email address: <input type="text" name="email" size=30><p> How did you reach this site? <select name="howreach"> <option value=0 selected>Choose one... <option value=1>Typed the URL directly <option value=2>Site is bookmarked <option value=3>A search engine <option value=4>A link from another site <option value=5>From a book <option value=6>Other </select><p> How would you rate the content of this site?<br> Poor <input type="radio" name="rating" value=1> 1 <input type="radio" name="rating" value=2> 2 <input type="radio" name="rating" value=3> 3 <input type="radio" name="rating" value=4> 4 <input type="radio" name="rating" value=5> 5 Excellent<p> Are you involved in any of the following? (check all that apply):<br> <input type="checkbox" name="des" value=1> Website Design<br> <input type="checkbox" name="svr" value=1> Web Server Administration<br> <input type="checkbox" name="com" value=1> Electronic Commerce<br> <input type="checkbox" name="mkt" value=1> Web Marketing/Advertising<br> <input type="checkbox" name="edu" value=1> Web-related Education<br> <p> Any other comments?<br> <textarea name="comments" rows=5 cols=70 wrap="VIRTUAL"> </textarea> <p> <input type="submit"> </form> </body></html>
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]