Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Submit Data from URL

Posted on 2002-05-31
5
Medium Priority
?
242 Views
Last Modified: 2010-03-05
How can I do this:
When a visitor goes to www.mydomain.com/script.cgi?data=INFO


INFO is written to a file on the server?

Something along the lines of :

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

? I don't know.
0
Comment
Question by:phita
  • 4
5 Comments
 
LVL 5

Accepted Solution

by:
amandeep earned 1500 total points
ID: 7048367
phita,

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 ------------------------------------
#!/usr/bin/perl

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";
close(FILE);

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

-------------------------------------------------

Hope this helps ..

Aman.
:-)
0
 

Author Comment

by:phita
ID: 7048971
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=http://www.mydomain.com/"></head></html>\n";


but I get an error.
0
 

Author Comment

by:phita
ID: 7048973
also, instead of having ?data=INFO , can I have:

script.cgi?INFO ? Thanks!
0
 

Author Comment

by:phita
ID: 7048980
alright, I got the REDIRECTing thing to work,


the only little problem is the ?data=INFo one.
0
 

Author Comment

by:phita
ID: 7048986
w00t thanks alot i got it all figured out. thanks alot
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
Six Sigma Control Plans

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question