Solved

Generate a Post

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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XSLT 5 47
Clean URL from GET variables 2 112
SEO friendly way to have two domains on website 9 94
CSS Question.. 3 92
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…
I will show you how to create a ASP.NET Captcha control without using any HTTP HANDELRS or what so ever. you can easily plug it into your web pages. For Example a = 2 + 3 (where 2 and 3 are 2 random numbers) Session("Answer") = 5 then we…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…
HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

791 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