I have a PHP file that spits out a form. I want to call this PHP file server-side, (currently using “include”), fill it in, and submit it.
This is better so I don’t have to meddle around with the actual form PHP, just deal with the presentation layer so the data gets understood by its own PHP file.
Is this possible? The form “method” is POST.
You won’t be able to fill in the form and submit it using
include(). Submitting a form means that it has to go over HTTP to a web server, so what you’re looking for is to emulate a POST request. PHP has a popular library called CURL to do this.Try something like this:
$outputwill contain the page output as if you had just submitted the form.