Submit Data from URL

How can I do this:
When a visitor goes to

INFO is written to a file on the server?

Something along the lines of :

open (FILE, ">>$datafile");
print FILE "$data\n";

? I don't know.
Who is Participating?
amandeepConnect With a Mentor Commented:

pls explain exatly what are u looking for..

If u want to save the data passed thru the url..
then this is what u can do:

---- script.cgi ------------------------------------

use CGI;
use strict;

my $datafile = '/path/tp/file.txt';
my $q = new CGI;
my $data = $q->param('data');

open (FILE, ">>$datafile");
print FILE "$data\n";

print $q->header;
print $q->start_html;
print "Data '$data' Stored";
print $q->end_html;


Hope this helps ..

phitaAuthor Commented:
ok, instead of having it display "data '$data' stored" can we have it redirect to a different site?

I tried

print "<HTML><HEAD><TITLE>one second</TITLE>\n";
print "<meta http-equiv="Refresh" content="0; url="></head></html>\n";

but I get an error.
phitaAuthor Commented:
also, instead of having ?data=INFO , can I have:

script.cgi?INFO ? Thanks!
phitaAuthor Commented:
alright, I got the REDIRECTing thing to work,

the only little problem is the ?data=INFo one.
phitaAuthor Commented:
w00t thanks alot i got it all figured out. thanks alot
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.