Perl,script,example,form,file,does,fill,will,
Quick Search for: in language:   
Perl,script,example,form,file,does,fill,will,
   Code/Articles » |  Newest/Best » |  Community » |  Jobs » |  Other » |  Goto » | 
CategoriesSearch Newest CodeCoding ContestCode of the DayAsk A ProJobsUpload
Perl Stats

 Code: 48,566 lines
 Jobs: 164 postings

 

You are in:

 
Login


Latest Code Ticker for Perl
randpass
By Joel Addams on 2/27


Programming Jargon, (with search)
By Benjamin Bechard on 2/26


CGI-Fortune with Extras
By Slava Shirokov on 2/23


TKase_tags.pl
By Incipient Cipher on 2/23


Printer Friendly Page v2
By Richard Leishman on 2/20


Click here to see a screenshot of this code!Centerized a String
By ram2i on 2/19

(Screen Shot)

Click here to see a screenshot of this code!Pyxus Pure Perl Web Server
By Alan Mollenkopf "BigAL" on 2/18

(Screen Shot)

Printer Friendly Page
By Richard Leishman on 2/16


Form to File
By Richard Leishman on 2/16


Click here to put this ticker on your site!


Add this ticker to your desktop!


Daily Code Email
To join the 'Code of the Day' Mailing List click here!





Affiliate Sites



 
 

 
 

   

Form to File

Print
Email
 
VB icon
Submitted on: 2/16/2002 9:57:58 PM
By: Richard Leishman  
Level: Intermediate
User Rating: Unrated
Compatibility:5.0 (all versions), Active Perl specific, 4.0 (all versions), 3.0 (all versions), Pre 3.0

Users have accessed this code 210 times.
 

(About the author)
 
     This Perl script is a example of form to file, what it does is when you fill in the form it will save it to a the file specified as a variable at the top. If you post more than once it puts them in the same file one after the other post. Fields can be added but will involve changing the cgi alittle, this is for webmasters who dont want users to submit their own made fields form their own made html forms (eg, trying to hack the script and mess it up). All you have to do is run the script, it has a form built in.
 
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!

    =**************************************
    = for :Form to File
    =**************************************
    The Question is, if there was a copyright would it stop people anyway ;) lol
code:
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
 
Terms of Agreement:   
By using this code, you agree to the following terms...   
1) You may use this code in your own programs (and may compile it into a program and distribute it in compiled format for langauges that allow it) freely and with no charge.   
2) You MAY NOT redistribute this code (for example to a web site) without written permission from the original author. Failure to do so is a violation of copyright laws.   
3) You may link to this code from another website, but ONLY if it is not wrapped in a frame. 
4) You will abide by any additional copyright restrictions which the author may have placed in the code or code's description.

    =**************************************
    = Name: Form to File
    = Description:This Perl script is a exam
    =     ple of form to file, what it does is whe
    =     n you fill in the form it will save it t
    =     o a the file specified as a variable at 
    =     the top. If you post more than once it p
    =     uts them in the same file one after the 
    =     other post. Fields can be added but will
    =     involve changing the cgi alittle, this i
    =     s for webmasters who dont want users to 
    =     submit their own made fields form their 
    =     own made html forms (eg, trying to hack 
    =     the script and mess it up). All you have
    =     to do is run the script, it has a form b
    =     uilt in.
    = By: Richard Leishman
    =
    =This code is copyrighted and has    = limited warranties.Please see http://w
    =     ww.Planet-Source-Code.com/xq/ASP/txtCode
    =     Id.284/lngWId.6/qx/vb/scripts/ShowCode.h
    =     tm    =for details.    =**************************************
    
    #!/path/to/perl
    ##################
    # Please link me on your website
    # Http://www.L22.co.uk
    ##################
    #what the file will be saved as
    $save_to = "saved.txt";
    #starting to view page
    print "Content-type: text/html\n\n";
    #setting up form inputs
    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; 
    $value =~ s/<//g;
    $value =~ s/>//g;
    $FORM{$name} = $value;
    }
    #Choosing which root it will take
    if ($ENV{'QUERY_STRING'} =~ /Add/) { &Add; }
    elsif ($ENV{'QUERY_STRING'} =~ /Main/) { &Main; }
    else { &Main; }
    #This is the form you fill in
    sub Main {
    print "
    <form action=\"?Add\" method=\"post\">
    <input type=\"text\" name=\"field\" size=\"25\">
    <input type=\"submit\" value=\"Send\"><br>
    </form>\n";
    }
    #when you click Send it runs this
    sub Add {
    #saving the file
    open FILE, ">>$save_to" or print "[ERROR: Cannot open file to save to]";
    print FILE "$FORM{'field'}\n";
    $news = "$FORM{'field'}";
    close(FILE);
    }


Other 2 submission(s) by this author

 

 
Report Bad Submission
Use this form to notify us if this entry should be deleted (i.e contains no code, is a virus, etc.).
Reason:
 
Your Vote!

What do you think of this code(in the Intermediate category)?
(The codewith your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor See Voting Log
 
Other User Comments

 There are no comments on this submission.
 
Add Your Feedback!
Note:Not only will your feedback be posted, but an email will be sent to the code's author in your name.

NOTICE: The author of this code has been kind enough to share it with you.  If you have a criticism, please state it politely or it will be deleted.

For feedback not related to this particular code, please click here.
 
Name:
Comment:

 

Categories | Articles and Tutorials | Advanced Search | Recommended Reading | Upload | Newest Code | Code of the Month | Code of the Day | All Time Hall of Fame | Coding Contest | Search for a job | Post a Job | Ask a Pro Discussion Forum | Live Chat | Feedback | Customize | Perl Home | Site Home | Other Sites | About the Site | Feedback | Link to the Site | Awards | Advertising | Privacy

Copyright© 1997 by Exhedra Solutions, Inc. All Rights Reserved.  By using this site you agree to its Terms and Conditions.  Planet Source Code (tm) and the phrase "Dream It. Code It" (tm) are trademarks of Exhedra Solutions, Inc.