1224 Posted December 4, 2010 Share Posted December 4, 2010 how to post a plus "+" symbol through http post? #include <IE.au3> $val = "2+3" _WebPost($val) Func _WebPost($val) Local $form_action,$header,$sDataToPost,$oDataToPost,$oIE $form_action = "http://127.0.0.1/post.php" $header = "Content-Type: application/x-www-form-urlencoded" $sDataToPost = "value=" & $val & "&submit=OK"; $oDataToPostBstr = __IEStringToBstr($sDataToPost) ; convert string to BSTR ConsoleWrite(__IEBstrToString($oDataToPostBstr) & @CR) ; prove we can convert it back to a string $oIE = _IECreate() $oIE.Navigate( $form_action, Default, Default, $oDataToPostBstr, $header) EndFunc P.S. for post.php <?php var_export($_POST); ?> I expect I can see "2+3" on the page, but not 5!! Link to comment Share on other sites More sharing options...
AlmarM Posted December 4, 2010 Share Posted December 4, 2010 (edited) Try $val = String("3+2") Edited December 4, 2010 by AlmarM Minesweeper A minesweeper game created in autoit, source available. _Mouse_UDF An UDF for registering functions to mouse events, made in pure autoit. 2D Hitbox Editor A 2D hitbox editor for quick creation of 2D sphere and rectangle hitboxes. Link to comment Share on other sites More sharing options...
Mat Posted December 4, 2010 Share Posted December 4, 2010 I imagine using "+" would be how you do it. AutoIt Project Listing Link to comment Share on other sites More sharing options...
Mat Posted December 4, 2010 Share Posted December 4, 2010 (edited) I imagine using "+" would be how you do it. Kk, the forum turns it to a + & # 4 3 ; with no spaces Edit: Oh dear, not a good day. First the + won't work, and then it won't let me delete the above post, which looks rather stupid now (Telling the op to use ) Edited December 4, 2010 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
1224 Posted December 6, 2010 Author Share Posted December 6, 2010 anyone can help? Link to comment Share on other sites More sharing options...
trancexx Posted December 6, 2010 Share Posted December 6, 2010 Is this AutoIt or PHP question? Looks to me it's more PHP. ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
czardas Posted December 6, 2010 Share Posted December 6, 2010 (edited) I don't know the syntax, but I imagine that you can create the php valid string. Perhaps use a hex value or something like that. It's just an idea. I imagine that should stop php parsing the variable. Have you tried: $val = "'2+3'"? Edited December 6, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
1224 Posted December 6, 2010 Author Share Posted December 6, 2010 It is autoit problem! $oIE.Navigate( $form_action, Default, Default, $oDataToPostBstr, $header) after this, the "plus" symbol will be disappeared. The problem is not the line $val = "2+3" It is because I tried MsgBox(0, "Debug", $var) and it shows 2+3 Link to comment Share on other sites More sharing options...
trancexx Posted December 6, 2010 Share Posted December 6, 2010 It is autoit problem! $oIE.Navigate( $form_action, Default, Default, $oDataToPostBstr, $header) after this, the "plus" symbol will be disappeared. The problem is not the line $val = "2+3" It is because I tried MsgBox(0, "Debug", $var) and it shows 2+3 No, it's not. Don't use exclamation mark for that, makes you look dumb considering it's not true. This would evaluate to true: (!It is autoit problem) ♡♡♡ . eMyvnE Link to comment Share on other sites More sharing options...
Mat Posted December 6, 2010 Share Posted December 6, 2010 have you tried my suggestion? & # 4 3 ; without the spaces. AutoIt Project Listing Link to comment Share on other sites More sharing options...
James Posted December 6, 2010 Share Posted December 6, 2010 So what do you want the output to be? If you want it to display 5 on the screen, then your PHP code would have to execute the actual code. If you want to display literally 2+3 on the screen, then you need to convert the + to the URL format (I forget if it's ASCII or what-not). James Blog - Seriously epic web hosting - Twitter - GitHub - Cachet HQ Link to comment Share on other sites More sharing options...
czardas Posted December 6, 2010 Share Posted December 6, 2010 I'm also curious to know which of the three possible return values you get with: $val = "'2+3'"What does it produce: 5, 23 or 2+3? operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Mat Posted December 6, 2010 Share Posted December 6, 2010 (edited) "2%2B3" I was just off... I was trying to use html encoding not url. Local $aArray[5] = [4, "2+3", "'2+3'", "2+3", "2%2B3"] For $i = 1 to $aArray[0] ConsoleWrite($aArray[$i] & ' ==> ' & _WebPost($aArray[$i]) & @LF) Next Func _WebPost($val) $form_action = "http://127.0.0.1/test/post.php" $header = "Content-Type: application/x-www-form-urlencoded" $sDataToPost = "value=" & $val & "&submit=OK"; Return SendHTTP($form_action, $sDataToPost) EndFunc Func SendHTTP($sURL, $sData) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $sURL) $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($sData) Return $oHTTP.Responsetext EndFunc ;==>SendHTTP result: 2+3 ==> Array ( [value] => 2 3 [submit] => OK ) '2+3' ==> Array ( [value] => '2 3' [submit] => OK ) 2+3 ==> Array ( [value] => 2 [submit] => OK ) 2%2B3 ==> Array ( [value] => 2+3 [submit] => OK ) Edited December 6, 2010 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
czardas Posted December 6, 2010 Share Posted December 6, 2010 (edited) I thought the first and third return values would be 5. What's the difference? Edited December 6, 2010 by czardas operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Mat Posted December 6, 2010 Share Posted December 6, 2010 (edited) The difference is that the forum turns: "+" into "+"That's why I sound pretty dum in my first few replies.Local $aArray[5] = [4, "2+3", "'2+3'", StringStripWS("2 &# 43 ; 3", 8), "2%2B3"] For $i = 1 to $aArray[0] ConsoleWrite($aArray[$i] & ' ==> ' & _WebPost($aArray[$i]) & @LF) Next Func _WebPost($val) $form_action = "http://127.0.0.1/test/post.php" $header = "Content-Type: application/x-www-form-urlencoded" $sDataToPost = "value=" & $val & "&submit=OK"; Return SendHTTP($form_action, $sDataToPost) EndFunc Func SendHTTP($sURL, $sData) $oHTTP = ObjCreate("winhttp.winhttprequest.5.1") $oHTTP.Open("POST", $sURL) $oHTTP.SetRequestHeader("Content-Type", "application/x-www-form-urlencoded") $oHTTP.Send($sData) Return $oHTTP.Responsetext EndFunc ;==>SendHTTP Edited December 6, 2010 by Mat AutoIt Project Listing Link to comment Share on other sites More sharing options...
czardas Posted December 6, 2010 Share Posted December 6, 2010 The difference is that the forum turns: "+" into "+"lol operator64 ArrayWorkshop Link to comment Share on other sites More sharing options...
Mat Posted December 6, 2010 Share Posted December 6, 2010 lolIt took me a long time to try and get my point across. Anyway, it's done now, problem solved with "%2B". AutoIt Project Listing Link to comment Share on other sites More sharing options...
1224 Posted December 7, 2010 Author Share Posted December 7, 2010 thanks Mat 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