Web Analytics Made Easy -
StatCounter Saving submitted values from a form... - CodingForum


No announcement yet.

Saving submitted values from a form...

  • Filter
  • Time
  • Show
Clear All
new posts

  • Saving submitted values from a form...

    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.

  • #2
    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).


    • #3
      an example would be something like this:
      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";
      # 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 or one of O'Reilly's Books on Perl. if you don't like these, a google search for Perl Tutorial could provide something useful...
      "There is more than one way to do it."