: POST data to another form with php 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
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:
Customer provides information such as item to buy, purchase amount, shipping address etc.
Information will be saved into the database and will need to generate a new customer id.
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'.
More posts by @Deb1703797
2 Comments
Sorted by latest first Latest Oldest Best
You could opt to use a cookie method since if they refresh the page they could lose the post data.
For example:
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.
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.
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.
<?php
$target = 'path-to-post-processor.php'; //leave blank to submit to self
if(isset($_POST['submit']))
{
header('Location: 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" />
</form>
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.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.