Jump to content
Sign in to follow this  
1224

About "plus" symbol

Recommended Posts

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!!

Share this post


Link to post
Share on other sites

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 :graduated: )

Edited by Mat

Share this post


Link to post
Share on other sites

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 by czardas

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

"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 by Mat

Share this post


Link to post
Share on other sites

The difference is that the forum turns: "&#43;" 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 by Mat

Share this post


Link to post
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...