Mogato Posted July 16, 2009 Share Posted July 16, 2009 I want to send variables with POST instead of GET, but cannot seem to find how to do it :'( anyone who could help me? Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/ Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 send how? in an HTML form? <form action="somepage.php" method="POST"> <input type="text" name="field1" /> <input type="submit" /> </form> Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876530 Share on other sites More sharing options...
Maq Posted July 16, 2009 Share Posted July 16, 2009 I want to send variables with POST instead of GET, but cannot seem to find how to do it :'( anyone who could help me? That's a little hard to believe. There are plenty of example on phpfreaks, let a lone Google. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876557 Share on other sites More sharing options...
Mogato Posted July 16, 2009 Author Share Posted July 16, 2009 Sorry if I was a bit unclear... i need to send it using POST without a form... I have a webshop where the user can chose different payment methods and if the for an example choose credit card they will come to a page thats sends the data to payson... however payson needs to receive the data with POST instead of GET (if they could receive it with get I could send them one long URL with query strings) but it this case I don´t know how to get the page to collect all the variables and then send them with POST Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876560 Share on other sites More sharing options...
akitchin Posted July 16, 2009 Share Posted July 16, 2009 for this, you'll need to use sockets. there's probably some documentation on payson's site. if not, peruse the manual's section on sockets (starting with fsockopen) and maybe hop on over to paypal's development resources, because they have code samples that construct a request in the same way. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876586 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 Why can't you just use a form with hidden variables? Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876592 Share on other sites More sharing options...
akitchin Posted July 16, 2009 Share Posted July 16, 2009 Why can't you just use a form with hidden variables? because that would require the physical submission of the form, unless one was to use javascript to submit the form upon loading of the page, but one should avoid relying on javascript to make their app work. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876597 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 Why can't you just use a form with hidden variables? because that would require the physical submission of the form, unless one was to use javascript to submit the form upon loading of the page, but one should avoid relying on javascript to make their app work. No javascript needed. Put all the needed elements in a form...either hidden or inputs they can change...then a BUY button that submits the form to payson. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876598 Share on other sites More sharing options...
akitchin Posted July 16, 2009 Share Posted July 16, 2009 No javascript needed. Put all the needed elements in a form...either hidden or inputs they can change...then a BUY button that submits the form to payson. the only problem is that then you're at the mercy of payson, and are forced to physically send the user there. constructing with sockets allows for seamless integration. both perfectly doable ways, i guess it just depends on the OP's goal. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876604 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 I suspect the user MUST go there, so they can enter their credit card information for the payment Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876606 Share on other sites More sharing options...
akitchin Posted July 16, 2009 Share Posted July 16, 2009 touché my good man! OP: are you collecting credit card information on your site, or are they collecting it on payson's website? Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876608 Share on other sites More sharing options...
d.shankar Posted July 16, 2009 Share Posted July 16, 2009 Did somebody think of cURL ? Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876611 Share on other sites More sharing options...
akitchin Posted July 16, 2009 Share Posted July 16, 2009 Did somebody think of cURL ? another possibility, but i imagine it might be a little over the OP's head. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876612 Share on other sites More sharing options...
d.shankar Posted July 16, 2009 Share Posted July 16, 2009 LoL , ok Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876613 Share on other sites More sharing options...
Mogato Posted July 16, 2009 Author Share Posted July 16, 2009 I think that akitchin understands my problem... i have got one page called "checkout.php" on this page you can chose payment method either invoice or credit card (payson) - when the user has made his choice and press submit "order.php" is called and what it does is that it collects all the data such as name, address, totalprice etc. it also checks the payment method and if it is credit card (payson) it will send all the data to payson... my problem is that payson only can receive it as POST so if I only had one payment method i would just have one form that sent all the data directly to Payson however in this case I must first check the payment method and then send it forward with the right data. It is a bit complicated to describe, but I hope you understand? thanks a buch for all comments... Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876617 Share on other sites More sharing options...
akitchin Posted July 16, 2009 Share Posted July 16, 2009 I think that akitchin understands my problem... i have got one page called "checkout.php" on this page you can chose payment method either invoice or credit card (payson) - when the user has made his choice and press submit "order.php" is called and what it does is that it collects all the data such as name, address, totalprice etc. it also checks the payment method and if it is credit card (payson) it will send all the data to payson... my problem is that payson only can receive it as POST so if I only had one payment method i would just have one form that sent all the data directly to Payson however in this case I must first check the payment method and then send it forward with the right data. It is a bit complicated to describe, but I hope you understand? thanks a buch for all comments... in this case, one option is to have a final confirmation page (AFTER the user has selected payson as their payment method) with the hidden form inputs as rhodesa has suggested. otherwise, you could have them select the payment method BEFORE entering their information, which allows them to go straight from information entry to payment processor since you're already aware that they need to head that way. the final option, and probably the one that's more work, is going my route and constructing the POST request using sockets or cURL as mentioned above. with so many other options though, it's unlikely that this is worth the effort. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876622 Share on other sites More sharing options...
PFMaBiSmAd Posted July 16, 2009 Share Posted July 16, 2009 All of this depends on the exact method and architecture you are using to interface with the payment processor. For example, if the payment processor is expecting only the payment details, using a form with hidden fields will result in truck-loads of purchases that only cost the visitor $0.01 The payment processor's site will contain code examples that should be followed for any method or system architecture you are using. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876642 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 Basically....you can't. You could have the server send a POST with cURL or fsockopen(), but any session data that is started with the server can't be transferred to the user...so that won't work. And, once the user has submitted the data to your site, you can't force a redirect to payson with another post. The only thing you can do is output a form and submit it with javascript, which is a bad solution. If this site won't accept GET or doesn't have some API to do this stuff, you should probably look for a different credit card processing company. My recommendation is to make a review shopping cart page, that submits to a Payment method page. When it submits to this page, put any data you want to keep into your database. Then, if they click a local method, submit it to one of your pages, and if they click the credit card option, have it submit directly to payson (via a hidden form). You will end up with some extra records in your database from people going to the payment page, and then changing their mind...but just flag those records after a day and not receiving payment. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876645 Share on other sites More sharing options...
PFMaBiSmAd Posted July 16, 2009 Share Posted July 16, 2009 I'm guessing this is the payment processor in question? - https://www.payson.se/about/commerce/ Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876650 Share on other sites More sharing options...
Mogato Posted July 16, 2009 Author Share Posted July 16, 2009 Thanks for all the help... really appreciate it I think I´m gonna start looking for another credit card processing company.... anyone has any recommendations? Paypal? I want something thats not to expensive since I recently launched the shop and therefore doesnt have too many orders yet... Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876653 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 While there is something out there that is cheaper then PayPal, I consider it worth the money. User's seem so much more comfortable using that then entering their info on some site they have never heard of. Plus, the APIs they have are VERY in-depth Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876662 Share on other sites More sharing options...
Mogato Posted July 16, 2009 Author Share Posted July 16, 2009 While there is something out there that is cheaper then PayPal, I consider it worth the money. User's seem so much more comfortable using that then entering their info on some site they have never heard of. Plus, the APIs they have are VERY in-depth I managed to POST the variables finally... however I encountered another problem so I will try PayPal instead... this is the code to POST variables without using forms: <?php // // A very simple PHP example that sends a HTTP POST to a remote site // $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,"http://www.mysite.com/tester.phtml"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, "postvar1=value1&postvar2=value2&postvar3=value3"); curl_exec ($ch); curl_close ($ch); ?> Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876756 Share on other sites More sharing options...
rhodesa Posted July 16, 2009 Share Posted July 16, 2009 the problem with using curl is that the server is posting the data, not the client. so after you do the curl part, and send the user to payson to enter their credit card info, it doesn't know who the user is...again, cus the server made the post Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876760 Share on other sites More sharing options...
pengu Posted July 17, 2009 Share Posted July 17, 2009 2 different forms then? Make them select there method of payment first and depending on what that is, invoice or payson will determine what form they're presented with. Quote Link to comment https://forums.phpfreaks.com/topic/166221-php-post-form-variables/#findComment-876831 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.