0

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

Community
  • 1
  • 1
ReynierPM
  • 17,594
  • 53
  • 193
  • 363

3 Answers3

0

In PHP you can redirect users with the following statement:

header("Location: <your location>");
tim_a
  • 940
  • 1
  • 7
  • 20
0
if($_POST['youFormName'])
 {
 //whatever you do with your post data do here first then:
 header("Location: <your location>");
 exit;
 }
k to the z
  • 3,217
  • 2
  • 27
  • 41
  • @k to the z , best practice is always write `exit()` after `header()` – xkeshav Apr 21 '11 at 18:19
  • Didn't know about the exit best practice. What's the reason? You have my interest, sir. – k to the z Apr 21 '11 at 19:08
  • 1
    It's more than just best practice, but it's a necessity for a redirect header (location) or else the script will continue to execute and you might see output that you should not see. exit prevents further output from being displayed, obviously, so you won't see it. Obviously, you can't use exit if you use header to change the content type, etc. – Explosion Pills Apr 21 '11 at 19:41
  • Well certainly either of yours understand my question: I have a normal PHP page (will call page.php) where I have some data $total and $order_id. These data was submitted by a previous form. Then in page.php I have a button or a image or whatever. When I press this button I need to send the $total and $order_id to a remote JSP (will call page.jps) but at the same time I need to redirect to page.jsp. page.jsp will get $total and $order_id and process the information. Understand now? Cheers – ReynierPM Apr 23 '11 at 20:59
0


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

xkeshav
  • 53,360
  • 44
  • 177
  • 245