开发者

Send data via POST and then redirect to the same page

I've been reading a while before ask here but really need yours help on this topic. I found this amazing posts ([1],[2]) which is basically what I'm need but with some minor changes. This is my flow:

  1. The user is buying products in my page
  2. The user end and start the process to pay and shipping
  3. When the user arrive to the latest page before payment I have all the needed data to send via POST and to do online Payment
  4. In the other side exists a JSP which receive two parameters: total and invoiceNumber

I know I 开发者_运维知识库need to use cURL in order to send data via POST but I need to redirect also to the bank online payment page. How can I do this?

PS: Sorry for my english is not so good

[1] PHP - Redirect and send data via POST [2] http://davidwalsh.name/execute-http-post-php-curl


In PHP you can redirect users with the following statement:

header("Location: <your location>");



First of all welcome to Stack Overflow.

if all data is on your page then no need to use CURL. CURL is for cross domain. if u want to post and redirect on same page then do the action on same page ($_SERVER['PHP_SELF']); that's it.. make your page this way

if(isset($_POST)){
// do all the process with your post data
}
<form action="<?php echo $_SERVER['PHP_SELF']?>" method="post" name="shoppingForm">
//here is your  form detail
</form>

Note:PHP manual is best to learn


if($_POST['youFormName'])
 {
 //whatever you do with your post data do here first then:
 header("Location: <your location>");
 exit;
 }
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜