Page 1 of 1

Need help - remote filling in forms :)

Posted: Tue Sep 07, 2004 1:11 pm
by Peter VDD
I have a question, I want to make a mod which allows to remotely fill in a field somewhere on another website, how should i do this? is there a command for it?

Thanks a lot! :)

Greetz, Peter

Posted: Tue Sep 07, 2004 9:28 pm
by phulaeo
Well, three ways immediately come to mind.

First off, you could try making a link to the form using ".../form.php?textarea=".urlencode("a=1\nb=2\nc=3\na + b - c"); or something similiar. If it fills it in the textbox, you have a winner; just depends on how the form is coded. ;)

Second, you could try imitating the post on your site, i.e. copying their form code and changing the relative reference in ACTION="" to an absolute one, i.e. ACTION="form.php" becomes ACTION="http://remotesite.com/form.php".

Third, and this would be my choice, because it involves text parsing (MAN I love text parsing!), you could create a script that takes input for that field on your site; on submit, it could open itself or another script in a new window which would grab that form page, parse it until it found the text field/textarea you want (<textarea name="textarea" cols="60" rows="5" wrap="VIRTUAL"></textarea>, in the example you sent), and insert the input from your original form right between those start/end textarea tags. :mrgreen:

[ edit: method 3 would also entail changing the relative references to absolute, as the page still ends up on your site ]

Posted: Tue Sep 07, 2004 9:55 pm
by Peter VDD
Method 1 fails.
Method 2 isn't possible, since the path is <a href="javascript:document.form1.submit();>
Method 3: I got no clue how to do that :( could you give a simple example code? thanks :)

PS: if you could make the image render without the page loading, that's ok too. I know how the name of it gets rendered, so I can figure out the filename, and it is saved in a cache. In fact, that would even be easier. :)

Posted: Tue Sep 07, 2004 10:00 pm
by markus_petrux
Peter VDD wrote: Method 2 isn't possible, since the path is <a href="javascript:document.form1.submit();>

This is because that page uses a link instead of an INPUT TYPE="submit" element. It has the same effect, though.

Posted: Tue Sep 07, 2004 10:06 pm
by Peter VDD
markus_petrux wrote: This is because that page uses a link instead of an INPUT TYPE="submit" element. It has the same effect, though.


Still that doesn't solve my question :)

How can I make the image render remotely, i.e. how can I make my site click the submit button automatically after typing the text in that window? :)

Posted: Tue Sep 07, 2004 10:13 pm
by markus_petrux
Have you contacted their webmaster?



.

Posted: Tue Sep 07, 2004 10:59 pm
by Peter VDD
No... why would I need to contact their webmaster?

Posted: Tue Sep 07, 2004 11:06 pm
by phulaeo
This is the actual form on their site:

Code: Select all

<form name="form1" method="post" action="AoPS_L_TeXer.php">
<p> 
<textarea name="textarea" cols="60" rows="5" wrap="VIRTUAL"></textarea>
</p>

<p> <a href="javascript:document.form1.submit();"><img src="Images/Submit.gif" width="100" height="24" border="0"></a> 
</p>
                 
</form>
They use javascript, but all you need is a form with a textarea by the same name. Point your form to the AoPS_L_TeXer.php location (use an absolute URL) from your site, add a submit button (just set its value to submit, I would guess) and this method will probably be your best bet.

Posted: Wed Sep 08, 2004 6:08 am
by markus_petrux
It can be done by posting the form via sockets and then parsing the result to extract the image URI.

Not all hosts support PHP sockets, though.