hancham Posted September 7, 2011 Share Posted September 7, 2011 Ok my friends, I`m trying to send some data via POST using winhttp.au3 but it`s not working so far. I`m probably missing some detail about how using _WinHttpSendRequest or something. Please help! <autoit> ;variables $INPUT_NAME = "joe" $INPUT_PASSWORD = "joe" $adress = "www.test.com" $openS = _WinHttpOpen() $connector = _WinHttpConnect($openS, $adress) $openRequest = _WinHttpOpenRequest($connector, "POST", "/check.php","HTTP/1.1") $oPost = "username= $INPUT_NAME"; ;send it ;_WinHttpSendRequest($openRequest,"Content-Type: application/x-www-form-urlencoded" & @CRLF, "username=" & $INPUT_NAME & "&password=" & $INPUT_PASSWORD) ;receive response with INET $value = _INetGetSource ( "http://www.test.com/check.php" ) MsgBox(0, "The value is:", $value) </autoit> And this is my PHP code: <?php //Getting from app $user_login = $_POST['username']; $user_pass = $_POST['password']; echo $user_login; ?> So just for test I`m trying to echo the user_login to check if the autoit is passing the variable to php but It`s not! Link to comment Share on other sites More sharing options...
Mat Posted September 7, 2011 Share Posted September 7, 2011 Try this: I'm not sure what your problem is, and I haven't worked with the winhttp include before, but I know the method above has worked for me before. lyquy197 1 AutoIt Project Listing Link to comment Share on other sites More sharing options...
hancham Posted September 8, 2011 Author Share Posted September 8, 2011 Ow, thank you very much !! really worked! I was looking for it for so long ... Link to comment Share on other sites More sharing options...
ProgAndy Posted September 8, 2011 Share Posted September 8, 2011 You are reading the response in the wrong way. Here is an example, the helpfile contains some others. #include<WinHttp.au3> $hInternet = _WinHttpOpen() $hConnect = _WinHttpConnect($hInternet, 'snee.com') $sFirstName = "Jack" $sLastName = "Berk" $sSomeOtherURLEncodedVariables = "&a=123&test=void&foo=bar" $sPost = "fname=" & $sFirstName & "&lname=" & $sLastName & $sSomeOtherURLEncodedVariables $sResult = _WinHttpSimpleRequest($hConnect, "POST", '/xml/crud/posttest.cgi', '', $sPost) _WinHttpCloseHandle($hConnect) _WinHttpCloseHandle($hInternet) MsgBox(0, '', $sResult) splitx12 and Chiitus 2 *GERMAN* [note: you are not allowed to remove author / modified info from my UDFs]My UDFs:[_SetImageBinaryToCtrl] [_TaskDialog] [AutoItObject] [Animated GIF (GDI+)] [ClipPut for Image] [FreeImage] [GDI32 UDFs] [GDIPlus Progressbar] [Hotkey-Selector] [Multiline Inputbox] [MySQL without ODBC] [RichEdit UDFs] [SpeechAPI Example] [WinHTTP]UDFs included in AutoIt: FTP_Ex (as FTPEx), _WinAPI_SetLayeredWindowAttributes Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now