1

Is there another way to submit a form with values After page redirection beside JavaScript, Ajax or jQuery? with PHP only?

e.g page alpha.php has following example form;

<form action="beta.php" method="post" id="signupForm" class="signupForm" >
    <select name="payment" class="form-control" id="payment" required="required">
        <option value="">Select Payment Method</option>
        <option value="PayPal">PayPal</option>
        <option value="WorldPay">WorldPay</option>
    </select>
</form>

after above form submission, it will take to beta.php where after server side validation, redirect to either PayPal or WorldPay depend on option selected in above form,

<?php if(it's PayPal) { ?>
    <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post">
    <input type="hidden" name="cmd" value="_cart">
    <input type="hidden" name="business" value="seller@domain.com">
    <input type="hidden" name="item_name" value="hat">
    <input type="hidden" name="item_number" value="123">
    <input type="hidden" name="amount" value="15.00">
    <input type="hidden" name="email" value="jdoe@zyzzyu.com">
    // How to Submit it With PHP?
    </form>
<?php } else if (it's Worldpay) { ?>
    <form action="https://secure-test.worldpay.com/wcc/purchase" name=BuyForm method=POST>
    <input type="hidden" name="instId"  value="211619">
    <input type="hidden" name="cartId" value="WorldPay Test page">
    <input type="hidden" name="desc" value="">
    <input type="hidden" name="M_subject" value="WorldPay example">
    <input type="hidden" name="testMode" value="100">
    // How to Submit it With PHP?
    </form>
<?php } ?>

Is it possible or not?

Shehary
  • 9,548
  • 9
  • 33
  • 66
  • So you want PHP to make a POST request is that the question? – chris85 Oct 25 '15 at 15:49
  • @chris85 yup that's the question, searched but haven't found even single reference that it's possible – Shehary Oct 25 '15 at 15:51
  • Take a look at this, http://stackoverflow.com/questions/2138527/php-curl-http-post-sample-code. CURL should be able to do it. – chris85 Oct 25 '15 at 15:52
  • @chris85, thanks cURL is the solution, so just have to remove the forms, init cURL , define URL and Set it POST Method, define parameters or variables and good to go. – Shehary Oct 25 '15 at 16:06
  • Yup, the forms would be outputted which you don't want. Curl will(should) keep it all server side. Good luck. – chris85 Oct 25 '15 at 16:08
  • 1
    nice question, nice feedback @chris85 oh btw, go Patriots ! – Drew Oct 27 '15 at 15:16
  • 1
    @Drew nothing to fear with the pats; bruins though yeesh.. – chris85 Oct 27 '15 at 16:08

0 Answers0