Solved

Passing value pairs

Posted on 1999-01-12
4
241 Views
Last Modified: 2013-12-25
our customers, after payinging, end up at a page with the code below, then they click on the submit button on the page:
-----------------------------

<html>

<body bgcolor="#FFFFFF">

<center>

<table width="600">

<tr><td colspan="2"> rcpt header

                  

                  </td></tr>

<tr>

<td align="center" colspan="2">



<form method="POST" action="http://www.mydomain.com/cgi-bin/myscript.cgi">

<input type="hidden" name="INVOICE" value="1001">

<input type="hidden" name="DESCRIPTION" value="">

<input type="hidden" name="AMOUNT" value="$1.00">

<input type="hidden" name="CUSTID" value="4">

<input type="hidden" name="TYPE" value="NA">

<input type="hidden" name="METHOD" value="MasterCard">

<input type="hidden" name="NAME" value="vern keller">

<input type="hidden" name="ADDRESS" value="1922 some rd">

<input type="hidden" name="CITY" value="phoenix">

<input type="hidden" name="STATE" value="or">

<input type="hidden" name="ZIP" value="82370">

<input type="hidden" name="COUNTRY" value="USA">

<input type="hidden" name="PHONE" value="212-673-4637">

<input type="hidden" name="FAX" value="">

<input type="hidden" name="EMAIL" value="admin@mydomain.com">



<input type="submit" value="Continue">

</form>



</td>

</tr>

</table>

</center>



</body>

</html>


----------------------------

What I need to do is to have the script it is posting to (myscript.cgi)grab the CUSTID value (in the above example it is 4) and turn that into a variable (such as $CUSTID) for the script it is posting to.......which begins with multiple declarations like the following
-----------

#!/usr/local/bin/perl
require "dacfgv.pl";
$goodreferer = "http://www.goodplace.com/test.html";
$badferer = "http://www.goodplace.com/bad.html";
$adminname = "admin";
$username = "testuser1";
$password = "testpass1";

---------------------------
rest of script.........
0
Comment
Question by:vernk
[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
  • 3
4 Comments
 

Author Comment

by:vernk
ID: 1830575
Edited text of question
0
 

Accepted Solution

by:
oliverp101698 earned 50 total points
ID: 1830576
You can use the ReadParse subroutine that is a part of the
cgi-lib library to read your form data. First you will have
to require cgi-lib, using the following line:

require "/inetpub/scripts/library/cgi-lib.pl";
Note: your path will likely be different, locate the file
on your server first

then the command is:

ReadParse(*form_data);

which creates an associate array (hash) from your form data.
Note: if you don't supply your own hash name (form_data in
the above example) the default name is 'in'

Then you can access your form variables like this:

$CUSTID = $form_data{'CUSTID');

Does that help?


Oliver
0
 

Author Comment

by:vernk
ID: 1830577
Oliverp,
 Thank you!......I am running perl 5.0003 and i have searched the directories, but no cgi-lib.pl (i did find CGI.pm in the lib directory) Should i get cgi-lib.pl and put it in the lib directory so I can call it?
 Thanx again for all the help
0
 

Author Comment

by:vernk
ID: 1830578
Ok, I tried putting cgi-lib.pl in my cgi-bin.....and added the require and the parse, etc.......

Heres what i am trying to do:
 At the 11th line from the end of this scrip,(print LOG "$FORM{'username'}|$FORM{'name'}|$FORM{'email'}|$FORM{'password'}|$timeStr\n";) it opens LOG and writes the username, name, password, etc to the log file......I want to write the CUSTID value, that was passed from the form in my original message, to this line also. The entire script is below

------------------------
#!/usr/local/bin/perl
require "cfgdafpass.pl";
$goodreferer = "http://www.mydomain.com/testvk1.html";
$badferer = "http://www.mydomain.com/else.html";
$htpasswd_FILE = 'D:/host/123.456.789.12/http/test.txt';
$logfile = 'D:/host/123.456.789.12/http/dafcc.log';
$mailprog = '';
$cgiurl = 'http://www.mydomain.com/cgi-bin/dafpass.cgi';
$aua = '1';
$adminmail = "admin\@mydomain.com";
$adminname = "admin";
$adminpwd = "http://www.mydomain.com/admin.pwd";
$homepage = "Daf Cc Signup";
$thirtydays = "2592000";
$user1 = "user1";
$pass1 = "ntpass1";

&parse;

if($FORM{'action'} eq "regform") { &regform; }
elsif($FORM{'action'} eq "reg") { &reg; }
elsif($FORM{'action'} eq "rmfrm") { &rmfrm; }
elsif($FORM{'u'} eq "Delete User") { &rm; }
elsif($FORM{'a'} eq "Admin Override") { &rma; }
elsif($FORM{'action'} eq "lupfrm") { &lupfrm; }
elsif($FORM{'action'} eq "lup") { &lup; }
elsif($FORM{'action'} eq "apfrm") { &changepass; }
elsif($FORM{'action'} eq "changepass2") { &changepass2; }
elsif($FORM{'action'} eq "gen") { &gen; }
elsif($FORM{'action'} eq "gen2") { &gen2; }
else { &menu; }










sub menu {
if ($ENV{'HTTP_REFERER'} ne $goodreferer) {
       print "Location: $badreferer\n\n";
       exit 0;
     }
else
{
&Header("Signup","Signup");
print "<center><form action=\"$cgiurl\" method=\"POST\"><input type=\"hidden\" name=\"action\" value=\"regform\">\n";
print "<input type=\"submit\" value=\"Choose Username and Password\"></form><p>\n";
print "<center><form action=\"$cgiurl\" method=\"POST\"><input type=\"hidden\" name=\"action\" value=\"rmfrm\">\n";

&Footer;
}


sub regform
{
&Header("Choose","Choose","Username and Password");
print "<center><font color=#000080>Please fill out the form below:</font></center><br>\n";
print "<center><font color=#000080 size=-1><b>Correct email is required or membership will be cancelled</b></font></center><p>\n";
print "<form method=\"POST\" action=\"$cgiurl\"><center>\n";
print "<table border=\"0\" width=\"45%\"><tr>\n";
print "<td width=\"41%\">Name:</td><td width=\"59%\">\n";
print "<input type=\"text\" name=\"name\" size=\"20\"></td></tr>\n";
print "<tr><td width=\"41%\">Email address:</td><td width=\"59%\">\n";
print "<input type=\"text\" name=\"email\" size=\"20\"></td></tr>\n";
print "<tr><td width=\"41%\">Login name:</td><td width=\"59%\">\n";
print "<input type=\"text\" name=\"username\" size=\"20\"></td></tr>\n";
print "<tr><td width=\"41%\">Password:</td><td width=\"59%\">\n";
print "<input type=\"password\" name=\"password\" size=\"20\"></td></tr>\n";
print "<tr><td width=\"41%\">And again:</td><td width=\"59%\">\n";
print "<input type=\"password\" name=\"password2\" size=\"20\"></td></tr>\n";
if($aua eq "0") {
print "<tr><td width=\"41%\">Admin Password:</td><td width=\"59%\">\n";
print "<input type=\"password\" name=\"adpasswd\" size=\"20\"></td></tr>\n";
}
print "</table><input type=\"hidden\" name=\"action\" value=\"reg\">\n";
print "<input type=\"submit\" value=\"Add User\"></form></center>\n";
&Footer;
}

sub reg
{
if($aua eq "0") {
      open(ADM,"$adminpwd") || &error('File Error on password file');
      $adm = <ADM>;
      close(ADM);
      if($FORM{'adpasswd'} eq $adm) { goto register; }
      else { &error('Invalid password entered.'); }
}
else {
register:
open(HTPASS,"<$htpasswd_FILE") || &error('Could not find specified file');
@htpasswd = <HTPASS>;
close(HTPASS);

if($FORM{'username'} =~ /:/){&error('Do not use : in your username');}
if($FORM{'username'} =~ /\s/){&error('Do not use spaces in your username');}
if($FORM{'username'} eq ""){&error('No username entered');}
if($FORM{'password'} eq ""){&error('No password entered');}
if($FORM{'password'} ne $FORM{'password2'}){
&error('Your first password did not match your second');}
if(@match = grep(/^$FORM{'username'}:/, @htpasswd)){
&error("The username, $FORM{'username'} is already in use. Please click on back and choose another one.");}

$salt1 = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./';
$salt = substr($salt1,rand(length($salt1)),1);
$salt .= substr($salt1,rand(length($salt1)),1);
$password = crypt($FORM{'password'},$salt);


{
        $now = time();

        $timeStr = &manageDate( $now );
        print "\$now = $now\n\$timeStr = \"$timeStr\"\n";
}


sub manageDate
{
        local( $time_t ) = @_;

        ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime( $time_t );

        $year += 1900;
        $mon++;

        $str = sprintf( "%4.4d-%2.2d-%2.2d", $year, $mon, $mday );

        $str;
}




open(HTPASS,">>$htpasswd_FILE") || &error('Could not find specified file');
$datestr = &manageDate( $thirtydays+$now );
print HTPASS "$FORM{'username'}:$FORM{'password'}, $ntuser:$ntpass, $datestr\n";
close(HTPASS);

open(LOG, ">>$logfile") || &error('Could not find specified file');
print LOG "$FORM{'username'}|$FORM{'name'}|$FORM{'email'}|$FORM{'password'}|$timeStr\n";
close(LOG);


&Header("Membership Confirmation","Please Continue");
print "<center><font color=#000080>Thank You $FORM{'name'}!</font></center><p>\n";
print "<center>Please <a href=\"http://www.mydomain.com/home.htm\"><b> CONTINUE</b></a></center>";
&Footer;
}
}
}
0

Featured Post

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Introduction:   Welcome to my first article ever. To begin with, the reason I write this article.  I participated in a question on Experts Exchange about the start command in Windows and there were some discussion about the usage. The discussio…
This article will show, step by step, how to integrate R code into a R Sweave document
The viewer will learn how to count occurrences of each item in an array.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

734 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