Solved

Generate a Post

Posted on 2003-11-13
6
266 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
  • 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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
css help 3 124
Removing Flash from Website 6 65
Finding the platform that was used to build a website 4 50
Problem to picture file 3 74
Most of the sites are being standardized with W3C Web Standards. W3C provides lot of web standard services to the web. They have the web specification, process and documentation for all the web standards. You can apply HTML, CSS and Accessibility st…
What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
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.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

803 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