Solved

Submit Data from URL

Posted on 2002-05-31
5
230 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
5 Comments
 
LVL 5

Accepted Solution

by:
amandeep earned 375 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: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say 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

Suggested Solutions

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…
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
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…

734 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