Web Analytics Made Easy -
StatCounter One form element w/ date to file - CodingForum

Announcement

Collapse
No announcement yet.

One form element w/ date to file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • One form element w/ date to file

    I've got a form with something like this in it:
    Code:
    <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?

  • #2
    your form must only contain this.
    Code:
    <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:
    Code:
    #!/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";
    "There is more than one way to do it."

    Comment


    • #3
      great help but need more

      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?

      Comment


      • #4
        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.
        "There is more than one way to do it."

        Comment

        Working...
        X