any PHP/HTML experts here?

Cableguy

Expert
Licensed User
Longtime User
Hi guys...

I need to submit a web form in a automatic way...
The form uses "action=" and "method="POST""
I can easely gather the information I need to send, including the "hidden" names and values...
But how do i arrange this data in my httprequest?
It would be MUCH easier to simulate a click on the submit button, but it is somehow iludding me...
 

gmeader

New Member
Use the Javascript submit method

Use the Javascript submit method.

Example form:
<form name="myform" action="handle-data.php">
</form>

<SCRIPT language="JavaScript">
document.myform.submit();
</SCRIPT>
 

Cableguy

Expert
Licensed User
Longtime User
Use the Javascript submit method.

Example form:
<form name="myform" action="handle-data.php">
</form>

<SCRIPT language="JavaScript">
document.myform.submit();
</SCRIPT>

Thanks for the tip...
i got it workin by sending a click to the button...
 

bish0p

Member
Licensed User
Longtime User
Thanks for the tip...
i got it workin by sending a click to the button...

The other option is to really not interact with the form at all and just send the information, in a POST method call.

B4X:
wwwreq.Method="POST"
wwwreq.ContentType = "application/x-www-form-urlencoded"
writer.New1(wwwreq.GetStream,True)
s ="myUsername="&html.UrlEncode(username)&"&myPassword="&html.UrlEncode(password)&"&Button1=Login&__VIEWSTATE="&Viewstate&"&cookie=on"
buffer() = bit.StringToBytes(s,0,StrLength(s))
writer.WriteBytes(buffer())

Post is pretty simple really, all you need to do is create a string (in this example s) that is of the format varable=answer&varable=answer the answers must be URLencoded.

Other than that all I am doing is setting the method to POST and telling the server to expect everything in URLencoded form.

wwwreq is of corse a http request object and bit is a bitwize object, and writer is a binaryfile object.
 
Top