Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Submit Data from URL

Posted on 2002-05-31
5
Medium Priority
?
240 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 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

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…
There are many situations when we need to display the data in sorted order. For example: Student details by name or by rank or by total marks etc. If you are working on data driven based projects then you will use sorting techniques very frequently.…
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

715 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