PDA

View Full Version : One form element w/ date to file


Seawalker0903
02-27-2004, 07:34 PM
I've got a form with something like this in it:

<form action="/cgi-bin/form_handler_file" method=post>
<input type="hidden" name="savefile" value="loginids.txt">
<input type="text" name="idnum" size="20">
<input type="text" name="blah" size="20">
<input type="button" name="submit" value="submit" onclick=...>

I want to be able to append the "idnum" to the loginids.txt file along with the current date and time.

I've read webmonkey on perl/cgi but I'm just trying to write one form element w/ the date and being a newbie I'm lost!

Can someone point me in the right direction?

dswimboy
03-01-2004, 02:37 AM
your form must only contain this.

<form action="/cgi-bin/form_handler_file.cgi" method="post">
<input type="text" name="idnum" size="20">
<input type="button" name="submit" value="submit">

form_handler_file.cgi should look like this:

#!/usr/bin/perl

use CGI;

$idnum= $query->param("idnum");
$date = localtime;

open(LOG, ">> loginids.txt");
print LOG "$idnum $date\n";
close(LOG);

# print output page
print "Content-type: text/html\n\n";
print "thanks for logging in";

Seawalker0903
03-01-2004, 02:25 PM
your form must only contain this.

I need the other parts in the form to go to a password file... and I'll be getting login ids from other parts of the website. Can I still do this as I'm visualizing it or do I need to go at this differently?

dswimboy
03-01-2004, 06:26 PM
i said must only, not can only. you can include as many fields as you want. and you can have the script process as few of these as you want.