Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass form to file instead of email

Status
Not open for further replies.

alphanumero

Technical User
Oct 16, 2007
4
CA
You probably hear this a lot, but I'm a noob, and I know I'm jumping in way over my head, but here's what I want to do:
I want to create a form that instead of using the mailto: or the like, just appends its information to a log on the server for later reading. So far in my research, nothing has made itself obvious, but it strikes me this should be possible... Is it?
 
Hi

Of course it is possible. That is the normal processing flow, the [tt]mailto:[/tt] is just an aberration.

What programming language can you use on that server ?

Feherke.
 
heh, any language I want... it's mine, although I've already configged it for perl and don't really want to do too much work... I found a thread with a similar question, but it's closed, and doesn't really tell me how to pass the data from my form to the log (
I have the basic gist now, I just need to know how append the data ^_^
 
Hi

Certainly there are much better examples. This one is simple :
Code:
<form action="/cgi-bin/logit.pl">
Name : <input type="text" name="[b]name[/b]"><br>
Sex : <input type="radio" name="[b]sex[/b]" value="m">Male /<input type="radio" name="[b]sex[/b]" value="f">Female<br>
<input type="submit">
</form>
Code:
#!/usr/bin/perl

use CGI qw/:standard/;

[red]open FIL,">>logit.txt";
print FIL param("[b]name[/b]")."\t".param("[b]sex[/b]")."\n";
close FIL;[/red]

print header;
print "Form data saved";

Feherke.
 
Ok, so one more question... what do the \t and \n switches do?
if I want more variables, will that affect the \t and \n thingy?
 
Har! I figured it out... 1 or 2 internal server errors and I'm on the road! Thanks X20 million on this one ^_^
I really appreciate your help.
 
The CGI module has built in funtions for saving form data to file. Read the CGI documentation. Or you can do it manually like Feherke has shown you.

------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top