Solved

Generate a Post

Posted on 2003-11-13
6
272 Views
Last Modified: 2010-04-06
Am trying to post a merchant # but don't want it to be viewable in the source, so I am attempting to gather the data that was posted by the user, add the merchant #, and generate a post header to send the values to the merchant site.  I want the user to be taken to the merchant site as if the original form they submitted was submitting directly to it.
so basically, form A with values name=john & total=10 would be submited to page B where both name & day as well as a new value, merchant=123, would be automaticaly posted to page C.
Any ideas?
0
Comment
Question by:deadyak
[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
  • 2
6 Comments
 
LVL 35

Accepted Solution

by:
YZlat earned 24 total points
ID: 9742174
just use asp.

'***index.asp
<html>
<head>
<script LANGUAGE="javaScript">
<!--

function frmLogin_onSubmit() {
if (form1.name.value == "" || form1.total.value == "")
return false;
}

//-->
</script>
</head>
<body>
<form name="form1" method="post" action="processInfo.asp">
<iput type="text" name="name">
<iput type="text" name="total">
<input type="submit" name="submit1" value="Submit">
</form>
</body>
</html>

'***processInfo.asp
<%
Response.Buffer = true
for each obj in Request.Form
      with response
            .Write "<input type=""hidden"" name=""" & obj & """ value=""" & Request.Form.Item(obj) & """>" & vbcrlf
      end with
next

Dim strName, intTotal
strName=request("name")
intTotal=request("total")

'***
'construct merchant id
.....

'insert a record
strSQL="INSERT INTO..."
connObj.Execute(strSQL)

%>
0
 
LVL 1

Assisted Solution

by:jadecc
jadecc earned 23 total points
ID: 9745384
Hi,

If you want to do it in php, this is how I had to do it for my bank (BOA). It constructs a post header and submits it to the bank's receiveing form. The cool thing is that you can launch this from anywhere -- not just from the url approved by your bank.  You can subsitute the $formdata into what you need to send to the form:

                ///////////////////////////
                //send info to the bank
                ////////////////////////////
               
                //host info
                $host = "--YOUR BANK'S URL--";
                $port = 80;
                $path = "--PATH TO YOUR BANK'S FORM--";
               
                //create the array of form fields
                $formdata = array(  "ioc_merchant_id" => "--YOUR MERCHANT ID--",
                                    "ioc_order_total_amount" => $transTotal,
                                    "ioc_auto_settle_flag" => "Y",
                                    "ecom_billto_postal_name_first" => $firstname,
                                    "ecom_billto_postal_name_last" => $lastname,
                                    "ecom_billto_postal_street_line1" => $AddressLine1,
                                    "ecom_billto_postal_city" => $city,
                                    "ecom_billto_postal_stateprov" => $state,
                                    "ecom_billto_postal_postalcode" => $zipcode,
                                    "ecom_billto_postal_countrycode" => "US",
                                    "ecom_billto_online_email" => $email,
                                    "ecom_payment_card_name" => $cardHolderName,
                                    "ecom_payment_card_number" => $cardnumber,
                                    "ecom_payment_card_expdate_month" => $expMonth,
                                    "ecom_payment_card_expdate_year" => $expYear);
               
                //generate the post string
                foreach($formdata AS $key => $val)
                {
                    $poststring .= urlencode($key)."=".urlencode($val)."&";
                }
                //get rid of the last ampersand
                $poststring = substr($poststring, 0, -1);
               
                //open a socket
                $fp = fsockopen($host, 80, $errno, $errstr, 30);
               
                //check for error
                if(!$fp)
                {
                       print"SOCKET ERROR: $errstr ( $errno )<br>\n";
                }
                else
                {
                    fputs($fp, "POST $path HTTP/1.1\r\n");
                    fputs($fp, "Host: $host\r\n");
                    fputs($fp, "Referer: --THE URL THAT YOUR BANK APPROVED FOR TRANSACTIONS--");
                    fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
                    fputs($fp, "Content-length: ".strlen($poststring)."\r\n");
                    fputs($fp, "Connection: close\r\n\r\n");
                    fputs($fp, $poststring."\r\n\r\n");
                   
                    //loop through the response
                    if($debug) { print" getting response...<br>\n"; }
                    while(!feof($fp))
                    {
                        print fgets($fp, 4096);
                        print"<br>\n";
                    }
                   
                    //close the socket
                    fclose($fp);
                }

Hope that helps
jadecc
0
 
LVL 14

Expert Comment

by:Thandava Vallepalli
ID: 9747162
Hello,

Try this code.....

Server.Trasfer ( "c.asp" )
or
Server.Execute( "c.asp" )

Or go through the documentation about Transfer or Execute methods in msdn docuemntation....

all the best,
V.Thandava Krishna.
0
 
LVL 14

Assisted Solution

by:Thandava Vallepalli
Thandava Vallepalli earned 23 total points
ID: 9747185
Hello,

Here is the link for Transfer and execute methods....

http://www.4guysfromrolla.com/webtech/042602-1.shtml

All the best,
V.Thandava Krishna.
0

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Article by: Matthew
I am a very big proponent of technology compliance standards and strive to meet such criteria in all of my work. That includes my site, which is 100% XHTML 1.0 compliant as determined by the World Wide Web Consortium. https://www.matthewstevenkel…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

733 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