Solved

Generate a Post

Posted on 2003-11-13
6
262 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
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
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 the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

772 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now