Galaxy
Galaxy

Reputation: 25

Is it possible to automatically post a client's form from server side?

I did do some research before asking.

Submit form using only PHP? Without JavaScript?

I understand form submission is a client thing. People who answered the above question all rejected the possibility of automatically posting a form without JS. And they did have their points.

I believed they were right until I came across this article recently:

One who asked the question and the other who answered the question, in the end, they both confirmed that automatically post a form using PHP solely is workable. I tried to play around with their code but got a 408 error. Chrome says :

Failed to clear temp storage: It was determined that certain files are unsafe for access within a Web application, or that too many calls are being made on file resources. SecurityError

This article was pretty old though, so probably this solution used to work but it no longer suits modern browsers? Who was wrong?

Upvotes: 2

Views: 180

Answers (2)

Mikhail Zhuravlev
Mikhail Zhuravlev

Reputation: 1007

If you already have the required data in your script at that point where the form should be submitted, you can use this answer how-do-i-send-a-post-request-with-php#6609181. Otherwise you have to make you question more certain:

  • where the data comes from? what type is it?
  • what is the form receiver? (for example, there are sometimes CSRF checks)
  • are you sure you need to submit a form, not just make a POST request?

Upvotes: 1

Charlie
Charlie

Reputation: 23778

When you say "posting a client's form" it does the following things:

  1. Initialize form submission with data in the form fields via browser API.
  2. Send the POST/GET request to the destination server.

The step 1 can only be done in a client side - because the data is in the browser and PHP has no part in handling the browser when the page is fully loaded.

But step 2 can be done using almost any language and make the destination server record the data via TCP sockets. PHP is just a candidate here.

What your second article does is this.

Upvotes: 0

Related Questions