Sign in to follow this  
Followers 0
1224

About "plus" symbol

18 posts in this topic

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



#2 ·  Posted (edited)

Try

$val = String("3+2")
Edited 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.

Share this post


Link to post
Share on other sites

#4 ·  Posted (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 :graduated: )

Edited by Mat

Share this post


Link to post
Share on other sites

anyone can help?

Share this post


Link to post
Share on other sites

Is this AutoIt or PHP question?

Looks to me it's more PHP.


♡♡♡

.

eMyvnE

Share this post


Link to post
Share on other sites

#7 ·  Posted (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 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

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

Share this post


Link to post
Share on other sites

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?

Share this post


Link to post
Share on other sites

#13 ·  Posted (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 by Mat

Share this post


Link to post
Share on other sites

#14 ·  Posted (edited)

I thought the first and third return values would be 5. What's the difference?

Edited by czardas

Share this post


Link to post
Share on other sites

#15 ·  Posted (edited)

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

lol

It took me a long time to try and get my point across. Anyway, it's done now, problem solved with "%2B".

Share this post


Link to post
Share on other sites

thanks 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  
Followers 0