Quote: "return$=http request data("POST","sql_test/test1.php","data=egg123",0)"
Cowbox, you can use the function I wrote like this:
filename$ = "temp.html"
download("www.url.com/test1.php/?data=egg123",filename$)
OPEN TO READ 1, filename$
`read whatever
CLOSE FILE 1
function download(from$,to$)
if file exist(to$) then delete file to$
load dll "urlmon",1
LOAD DLL "wininet",2
failed_delete_cache = CALL DLL(2,"DeleteUrlCacheEntryA", from$)
failed=CALL DLL(1,"URLDownloadToFileA",0,from$,to$,0,0)
delete dll 2
delete dll 1
endfunction failed
You need to also make sure you encode the URL so that things like spaces and slashes and other special symbols are handled correctly and the client can make the request successfully. This function encodes the url, but does not prevent malicious attacks. I haven't posted it before, but because I'm feeling nice, here it is:
//This function takes text and converts it to valid
//url characters. This function does not do any
//security checks.
FUNCTION url_encode(string_to_encode AS STRING)
string_output AS STRING = ""
char_str AS STRING = ""
hex_code AS STRING = ""
FOR char = 1 TO LEN(string_to_encode)
char_str = MID$(string_to_encode,char)
ascii_code = ASC(char_str)
IF (ascii_code =< 32) OR (ascii_code => 159 AND ascii_code =< 191) OR (ascii_code => 159) OR (ascii_code => 34 AND ascii_code =< 38) OR ascii_code = 43 OR ascii_code = 44 OR ascii_code = 47 OR (ascii_code => 58 AND ascii_code =< 64) OR (ascii_code => 91 AND ascii_code =< 94) OR ascii_code = 96 OR (ascii_code => 123 AND ascii_code =< 126)
hex_code = RIGHT$(HEX$(ascii_code),2) //2 digits only!
string_output = string_output + "%" + hex_code
ELSE
string_output = string_output + char_str
ENDIF
NEXT char
ENDFUNCTION string_output
So the above code I gave you would look like this:
filename$ = "temp.html"
download("http://www.url.com/test1.php/?data=" + url_encode("egg123"),filename$)
OPEN TO READ 1, filename$
`read whatever
CLOSE FILE 1
function download(from$,to$)
if file exist(to$) then delete file to$
load dll "urlmon",1
LOAD DLL "wininet",2
failed_delete_cache = CALL DLL(2,"DeleteUrlCacheEntryA", from$)
failed=CALL DLL(1,"URLDownloadToFileA",0,from$,to$,0,0)
delete dll 2
delete dll 1
endfunction failed
//This function takes text and converts it to valid
//url characters. This function does not do any
//security checks.
FUNCTION url_encode(string_to_encode AS STRING)
string_output AS STRING = ""
char_str AS STRING = ""
hex_code AS STRING = ""
FOR char = 1 TO LEN(string_to_encode)
char_str = MID$(string_to_encode,char)
ascii_code = ASC(char_str)
IF (ascii_code =< 32) OR (ascii_code => 159 AND ascii_code =< 191) OR (ascii_code => 159) OR (ascii_code => 34 AND ascii_code =< 38) OR ascii_code = 43 OR ascii_code = 44 OR ascii_code = 47 OR (ascii_code => 58 AND ascii_code =< 64) OR (ascii_code => 91 AND ascii_code =< 94) OR ascii_code = 96 OR (ascii_code => 123 AND ascii_code =< 126)
hex_code = RIGHT$(HEX$(ascii_code),2) //2 digits only!
string_output = string_output + "%" + hex_code
ELSE
string_output = string_output + char_str
ENDIF
NEXT char
ENDFUNCTION string_output