Solved

Submit Data from URL

Posted on 2002-05-31
5
217 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 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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
hard perl script 16 156
Any syntax error for this clone.plscript 6 139
Perl Application JSON Receiving Strange Java Error 3 70
Regex rule to match two different url 5 72
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

773 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