HTML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignHTML 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 December 14th, 1999, 09:34 AM
kong
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Hello I would like to know whether it is possible to pass information between forms i.e. a persons name and company name.

This is what I would like to do.
I have a form which takes in a persons name and company name. Then that person proceeds to download files from my server on a different form. When that person downloads these files, I have a script that stores the name of the downloaded file. My problem is how do I also store the person's name with that file since the download page is on a different page?

In a nutshell, how do I pass the information from one form to another and keep the users information consistent i.e. possibly store the info in a variable on the users computer?

Can this only be done using cookies? Might there be other alternatives such as php3 or javascript?

Thank You for your time. If you need more info please email me or post the message here.

Raymond

Reply With Quote
  #2  
Old December 17th, 1999, 06:58 PM
12338323
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Make a real simple perl script, and post the information to the script. Place the HTML for the second page in the script and display said information with a variable.
Here is the code that you would need to do that. Post variable1 and variable2, then place $varable1 and $variable2 in the html for the second page:

#!/usr/bin/perl
print "Content-type: text/htmlnn";
&form_parse;
$variable1=$form('variable1');
$variable2=$form('variable2');


print <<endhtml

#put html in here

endhtml


sub form_parse {
read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$FORM{$name} = $value;
}}

Reply With Quote
  #3  
Old December 17th, 1999, 07:52 PM
Spookster
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Well you can create an invisible frame where all your script resides and stores the values of the form elements. What I mean by invisible frame is:

<frameset rows="0,*">
<frame src="invisiblepage.html" name="invisible">
<frame src="formapage.html" name="formpage">
</frameset>

Each time the user goes to a new page with a different form the values of the previous form will be stored in the invisible page which doesn't change.

Spookster

Reply With Quote
  #4  
Old December 21st, 1999, 08:21 PM
bag
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
I've had success doing the same type of stuff using hidden fields and the perl module CGI.pm.

let me know if you still need help on this one and I'll pass along some code.

Reply With Quote
  #5  
Old December 22nd, 1999, 08:26 AM
kong
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
Well I've tried Mr. 12338323 method but it somehow it gives me this error
HTTP 500 Internal Server error
and it won't let me display the HTML code.
I have some javascript in the code I wonder if that's it?

Well right now I got the same thing done using perl and php3. Essentially the same thing Mr. 12338323 is doing but instead of putting the HTML in the perl code itself, I parse the variables out to a php3 file which is the HTML page itself.

The only thing wrong with that is that is shows the variables in the URL. Is this an unsecure method?

I haven't tried using hidden frames. I'll try it out and let you know.

Well any help is appreciated so post away Mr. bag


Here's the code I'm using

#! /usr/local/bin/perl
use CGI;
$query = new CGI;
$query->import_names('R');

$R::File =~ s/ /+/g;

if ($R::File)
{
print $query->redirect("http://www.mydomain.net/pageone.php3?File=$R::File");
}
else {
print $query->redirect("http://www.mydomain.net/pagetwo.html");
}


[This message has been edited by kong (edited 12-22-99).]

Reply With Quote
  #6  
Old December 22nd, 1999, 09:16 PM
bag
Guest
Dev Shed Newbie (0 - 499 posts)
 
Posts: n/a  
Time spent in forums:
Reputation Power:
ok here is the basic idea.

#!/usr/local/bin/perl

use CGI;
$input=new CGI;
$firstName=$input->param('first_name');
$lastName=$input->param('last_name');

# the above parses the form entry from the #name input page.

print "<FORM ACTION="/cgi-local/nextStep.cgi" METHOD=POST>n";

print "<INPUT TYPE=hidden NAME="first_name" VALUE=$firstName>n";
print "<INPUT TYPE=hidden NAME="last_name" VALUE=$lastName>n";

print "</FORM>n";

#this next part takes the values that you parsed in the first section and puts them into hidden fields which the user cannot see but get passed back to the server when they hit the submit button.

The in the nextStep.cgi code, you parse the hidden fields using

$firstName=$input->param('first_name');
$lastName=$input->param('last_name');

just like you did in the first section. using this method, you can pass information from one form to the next. Its pretty raw but it works.

hope it helps.

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignHTML Programming > Passing information between forms


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 1 hosted by Hostway
Stay green...Green IT