I want to create a form on my page to get information this is easily done and the problem.

I want to 'POST' information to my own php-page, creating a new id and saving the information to my database. And then this page should redirect to the external page via 'POST' with id, price and so on.

The external page is a page to pay, so the customer should get this external site and should be able to use it like a normal page(maybe target="_blank").

In Short:

  1. Customer provides information such as item to buy, purchase amount, shipping address etc.

  2. Information will be saved into the database and will need to generate a new customer id.

  3. Page redirects to external payment page, sending id, price, payment information via 'POST'.

My problem is, how to redirect to the external page but sending custom information via 'POST'.

2 Answers 2


You can actually submit any form via POST to any page (even if it resides on a remote server). So as long as you specify the URL to the CGI page (PHP, PERL, Python), it should work.

In PHP, you can send header information (and therefore redirects) to any page on the local or a remote server, and have that happen after the form is submitted.

Of course in the example below, things are generalized. You'd want to add some qualifiers for "if form had an error" or "if unable to submit data" then don't send user to the new page. But hopefully the concepts prove helpful.

$target = 'path-to-post-processor.php'; //leave blank to submit to self
    header('Location: http://example.com/other/page.html');
<!--submit form via POST-->
<form action="<?php echo $target;?>" method="post">
<input name="something" type="text" maxlength="12" />
<input name="submit" type="submit" />

I'm also assuming you've got the database set up already. If you are still having trouble, add more details to your question (what have you tried, what are the errors) and we can go from there.

  • I tried it but the remote script didn't get my input. That's what I want
    – robin591
    Commented Mar 21, 2013 at 21:34

You could opt to use a cookie method since if they refresh the page they could lose the post data.

For example:

  1. Customer fills in address information and other details that is then saved into the MySQL database and is assigned a unique customer ID. This id is then saved as a cookie on the customers machine - Once cookie has been saved you then forward them to the next page which is the payment page.

  2. On the payment page you then retrieve SQL data based on customer ID held in Cookie.

Another way is no redirecting and use a Ajax solution.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.