0

I'm stuck in a problem.

Please see the example below

<form action="http://url-1.com/action">

------
------
</form>

Now when the form action parse variables then it redirects to another url like http://urls-2.com/confirm.php. See form action was sent to url-1.com/action

Since it redirected to a different url I can't capture response for the form action. Can any one help with proper example?

mmmmmm
  • 32,227
  • 27
  • 88
  • 117

1 Answers1

0

Try to put something like this as your "confirm.php" page:

<html>
 <body>
  <?php
   $title = $_POST['title'];  // 'title' is the field name in your form
   $name = $_POST['name'];    // 'name' is the field name in your form

   echo "Hello ". $title . " " . $name . "!<br />";
  ?>
 </body>
</html>
Yannick Blondeau
  • 9,465
  • 8
  • 52
  • 74
  • I'm looking for a solution in PHP. Because in booking step I'm stuck and 99% coding is done and its in PHP. – user1434610 Jun 04 '12 at 08:21
  • If you check then you'll see that I'm sending post values to an external url (url-1.com) and when it process then it redirects to url-2.com Since it gets redirected so can't capture response. – user1434610 Jun 04 '12 at 10:31
  • I noticed that but it should work anyway. You can check [this question](http://stackoverflow.com/questions/1324829/how-to-enable-cross-domain-post-ing-in-php) to see if you have the same problem. – Yannick Blondeau Jun 04 '12 at 11:15
  • 1
    I think the best solution would be to add a form to your `url-1.com/action` page that will duplicate all the data and then will be submitted to `urls-2.com/confirm.php`. You can then use javascript to auto-submit the form as explained [here](http://stackoverflow.com/questions/5576619/php-redirect-with-post-data). – Yannick Blondeau Jun 04 '12 at 11:54
  • Its not like that. Just imagine the paypal gateway integration. You'll be sending form data to paypal.com/webscr.... now paypal will process data and now response will come from say www.paypal-objects.com/url and the response is in xml. This is just an example. I need to capture the xml response. – user1434610 Jun 04 '12 at 12:05
  • I try to summarize it: you send data from `url1/action` to another domain (say, Paypal) and you want to redirect their XML output to another domain `url2/confirm.php`. Am I right? I think you should have an option to specify the target after their processing. If they prevent you from using another domain, they may have good reasons... – Yannick Blondeau Jun 04 '12 at 12:21
  • Actual issue is I'm sending form action to one url and after parsing it gets redirected to second url to show the xml response. Since it moves away to another domain, so I can't capture response of the 2nd domain. Can you kindly guide me with a real example code? – user1434610 Jun 04 '12 at 13:36
  • Can you give first a full example of your existing code? It would help a lot... Thanks! – Yannick Blondeau Jun 05 '12 at 06:31
  • Can I have your mail id to send ? Code is long. – user1434610 Jun 05 '12 at 07:57
  • Can't you edit your question to provide only the meaningful pieces of code? – Yannick Blondeau Jun 05 '12 at 08:59
  • Its still longer than 600 characters limit of stackoverflow. – user1434610 Jun 06 '12 at 05:12