PDA

View Full Version : Saving submitted values from a form...


BenJam
02-12-2004, 01:46 AM
Hey I was wondering if anyone could help me, I have a number of radio buttons with different values and I would like to know how to write these values to a file when they are submitted.

mlseim
02-12-2004, 05:05 AM
You need to process them with a "server-side" script written in something like Perl/CGI or PHP. The script will take-in the values, open a file and write them in. The file would of course be on the webhost server (not your PC).

dswimboy
02-20-2004, 02:11 AM
an example would be something like this:

#!/usr/bin/perl

use CGI;
$query = new CGI;

# get data from from
$text1 = $query->param("text1");
$radio1 = $query->param("radio1");

#write data to file
open(OUT, ">> radio.txt")
print OUT $text1 . " " . $radio1 . "\n";
close(OUT);

# output result
print "Content-type: text/html\n\n";
print "done";


The file above might be saved as "process.cgi" and the action of the form would be "process.cgi". This script extracts values from the form elements named 'text1' and 'radio1'. it then opens the file radio.txt for APPENDING or creating. the script appends the value of text1 and radio1 sepearted by a space on it's own line.
I am not sure how perl processes radio buttons from forms. you would have to do some experimentation.

this is a crash course in processing forms with Perl. hopefully you have some scripting or programming expierence. if not, i would recommend Webmonkey's Intro to Perl for CGI (http://hotwired.lycos.com/webmonkey/98/47/index2a.html?tw=programming) or one of O'Reilly's Books on Perl (http://perl.oreilly.com/). if you don't like these, a google search for Perl Tutorial could provide something useful...