Solved

Submit Data from URL

Posted on 2002-05-31
5
199 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
Comment Utility
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
Comment Utility
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
Comment Utility
also, instead of having ?data=INFO , can I have:

script.cgi?INFO ? Thanks!
0
 

Author Comment

by:phita
Comment Utility
alright, I got the REDIRECTing thing to work,


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

Author Comment

by:phita
Comment Utility
w00t thanks alot i got it all figured out. thanks alot
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

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…
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…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

772 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now