2

It has recently come to my attention that there is a tiny group of people that has JS disabled.

The paymentprovider's system works in such a way that you have to POST data to their payment portal and then after completion the user is sent to ReturnURL.

The setup I use now is with JS, it just Submits onload.

<html>
        <head>
        </head>
        <body onload="document.frm1.submit()">
            <form method="post" action="<?php echo $connectorUrl ?>" name="frm1">
                <input type="hidden" name="Data" value="<?php echo $data ?>">
                <input type="hidden" name="InterfaceVersion" value="<?php echo $interfaceVersion ?>">
                <input type="hidden" name="Seal" value="<?php echo $seal ?>">
            </form>
        </body>
    </html>

which means it wont work for people with JS disabled.

I've come across a lot of cURL solutions, but they don't actually send the user to the URL, they just return the results to a variable.

So to summarize; I need to send POST data as if it were using a regular 'submittable' form, but without JS to auto submit the form.

7
  • So you need that when all fields are filled automatically form data will post? Commented May 2, 2015 at 14:25
  • 1
    I think one of the valid reasons for people disabling JavaScript is exactly this. If I want to post a form, I'll post the form myself. Commented May 2, 2015 at 14:27
  • Be sure to use htmlspecialchars() around any arbitrary data used in the context of HTML. Otherwise, you risk creating invalid HTML and XSS attacks in some situations. Commented May 2, 2015 at 14:47
  • The thing is, this is to successfully pay in a checkout area, so if they want to be able to pay this has to be done for the system to work properly. P.S. Drenmi, this is not an answer. Commented May 2, 2015 at 15:33
  • Yes, all fields are generated by the system, the fields are necessary for the payment provider to be able to know which merchants started this payment, what amount they're paying for etc. Commented May 2, 2015 at 15:36

1 Answer 1

1

You cannot trigger a form submit without JS on the client.

Alternatively... inside your form...

    <button type="submit">Continue...</button>
</form>

It isn't automatic, but at least they will easily be able to continue... otherwise, you would need to submit this information from whatever resource is rendering the form to begin with from server to server.

Sign up to request clarification or add additional context in comments.

5 Comments

Okay, so let me explain this once more, for the customers to complete a payment, they have to enter a shopping cart screen and click go to checkout, then the system inserts all the necessary transaction and order information into the database and it should go to the payment portal. If it doesn't do that automatically, how do I ensure people actually land there...
What's strange to me is, you can use cURL to post to a URL and retrieve the data that is being sent back from that page. But you can't actually POST like a regular form. This seems odd to me.
I think I understand where you're coming from if the JavaScript is disabled, it wont be as smooth, but they can still continue manually. Is that what you meant?
@NathanPrins exactly.. I would put a submit button for those users without JS.. that way they can handle it manually... however, you should be able to do a server to server post if there isn't additional information needed.
Thanks, it seems the most elegant solution. Yeah, I thought so too, because you can retrieve information returned from a post request (Like a JS Ajax request) with cURL, but can't actually visit that page? Seems strange.

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.