Madi
Madi

Reputation: 47

How to make php script fill remote forms and submit?

To make this short, I will show what I need exactly. Here is the site, it shows some info about game stats once entered username and region.

http://riot.control-c.ir/
http://riot.control-c.ir/Summoner/EUW/26233693

How can I make remote submitting these forms to parse pages for different users?

Upvotes: 1

Views: 4292

Answers (1)

Shiplu Mokaddim
Shiplu Mokaddim

Reputation: 57650

THis can be done by copying the same http request that the remote form makes when it submits.

See the following form,

<form action="submit.php" method="post">
<input type=text name="username" />
<input type=text name="password" />
<input type=submit name="submit" value="Submit"/>
</form>

When this form is submitted there is an http request sent to submit.php on the remote host with post method. and in the body these fields reside.

username=MYUSERNAME&password=MYPASSWORD&submit=Submit

The http request looks like

POST submit.php
Host: remotehost.com
Accpet: */*
Content-Type: x-www-form-urlencoded
Content-Length: 43

username=MYUSERNAME&password=MYPASSWORD&submit=Submit

All you have to do is mimic this request.

Curl is a popular library for this task.

Upvotes: 2

Related Questions