Perl Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming LanguagesPerl Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 7th, 2001, 08:47 AM
Jorden Jorden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 Jorden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question HTML form -> script -> script

Here is what I am trying to do:

1. I have a HTML file with a form that posts to file2.cgi
file2.cgi only supports form-input, so no parameters.
I do not have access to file2.cgi, so I cannot change it.

2. I want the form to go through my file1.cgi file first, so I can log the statistics.

Question: How can I pass the information from file1.cgi to file2.cgi? Remember, I can not change file2.cgi!!! Is it even possible?
If not, do you think it is in PHP?

Reply With Quote
  #2  
Old June 7th, 2001, 09:49 AM
mullaney mullaney is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 0 mullaney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Jorden,

Most likely this is possible. Can you post your HTML code?

Bob

Reply With Quote
  #3  
Old June 7th, 2001, 09:56 AM
Jorden Jorden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 Jorden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
HTML code...

============================================
<FORM METHOD=post ACTION="http://195.81.38.162/OTA/RTTTL/1725217328">
<input type="hidden" size="30" NAME="composer" VALUE="16C2 16C1 16C1 16- 8C1 8- 8C1 8D1 8E1 8B1 8- 8B1 8- 8B1 8- 8B1 16C2 16C1 16D1 16D1 16C1 16C1 16C1 16- 8C1 16- 16C1 8C1 8D1 8E1 8D1 8- 8D1 8- 8D1 16F1 16- 16F1 16- 16E1 16- 16B1">
<input type="hidden" size="30" NAME="title" VALUE="Exploratio">
<input type="hidden" size="30" NAME="tempo" VALUE="160">
<input type="hidden" value="http://www.mobileringtonez.com/nl/success.shtml" size="10" name="url_success">
<input type="hidden" value="http://www.mobileringtonez.com/nl/error.shtml" size="10" NAME="url_failure">

<TABLE BORDER=0 CELLPADDING=0 CELLSPACING=2>
<TR><TD><FONT FACE=Arial SIZE=2>Ontvanger:</TD><TD><input type="text" name="recipient" value="316"></TD></TR>
<TR><TD><FONT FACE=Arial SIZE=2>Code:</TD><TD><input type="text" name="authcode"></TD></TR></TABLE>

<input type="submit" value="Versturen">
</form>
============================================

This was the original form. However, now I want it to go through my own .cgi file ....

Reply With Quote
  #4  
Old June 7th, 2001, 11:51 AM
mullaney mullaney is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Posts: 0 mullaney User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Question Solution

Consider this approach...

1. Original HTML Form calls your logging cgi script.
2. Your logging script creates and outputs a new HTML page in response, which presents itself as a "Verify Your Information" page. Some form elements will still remain hidden. Be sure to pass the original values back to the same form names in this step.
3. Have your user click a button confirming the information or they click another button that will return them to the original HTML form page.

If you would like the example code, let me know. This will add one extra web page, but will be disguised as Value-Added Service on your part.

Bob

Reply With Quote
  #5  
Old June 7th, 2001, 02:36 PM
dkode dkode is offline
PHP/PERL/.NET Coder
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2001
Location: Daytona Beach, Florida
Posts: 36 dkode User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 41 sec
Reputation Power: 8
Send a message via AIM to dkode
Shorter solution

I've done something similar to this before without having to use a confirmation page.

In your file1.cgi you would use LWP::UserAgent and simulate a browser. More documentation on LWP can be found at perldoc.com and searching for LWP::UserAgent. Your code would look some thing like this:

#!/usr/bin/perl

use LWP::UserAgent;

# Create UA Object
$ua = LWP::UserAgent->new;
$ua->agent("MyAgent");

# Request type: POST,GET etc...
my $req = HTTP::Request->new(POST => 'http://www.server.com/url/to/file2.cgi');
$req->content_type('application/x-www-form-urlencoded');

# Declare Variables to Post
$req->content("value1=$value1&value2=$value2");

# Send Request
$request = $req->as_string;
my $res = $ua->request($req);
$result = $res->as_string;

print "Content-Type: text/html\n\n";
print "$result\n";


THats a little crude but you get the idea. Basically you're taking all the info they submitted then posting it to another script using this one. Then the result sent from file2.cgi would then be piped through this script and to the client. Works very well..

Hope this helps
__________________
"Mankind cannot define memory, yet it defines mankind"

Reply With Quote
  #6  
Old June 7th, 2001, 03:20 PM
Jorden Jorden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 Jorden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Talking Thank you...

Thank you both for your replies. Ofcourse, the confirmation thing is a very good idea that I hadn't thought of myself...but I think the second reply will fit my needs better, so I will try that out ASAP!

Thanks!

Reply With Quote
  #7  
Old June 8th, 2001, 08:47 AM
Jorden Jorden is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jun 2001
Posts: 0 Jorden User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Thanks dkode, it worked fine!!!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPerl Programming > HTML form -> script -> script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway
Stay green...Green IT