Solved

Generate a Post

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

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

Preface This article introduces an authentication and authorization system for a website.  It is understood by the author and the project contributors that there is no such thing as a "one size fits all" system.  That being said, there is a certa…
Preface In the first article: A Better Website Login System (http://www.experts-exchange.com/A_2902.html) I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
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.
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…

726 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