Home > Software engineering >  Vb post multiple parameters of problem?
Vb post multiple parameters of problem?

Time:09-17

Everybody to help me have a look at what's the problem?
PHP returns only "user name", but "aaa" display not receive, display,
Because to transmit pictures base64 data, so want to use the post way,



Vb
 
The Set HttpClient=CreateObject (" Microsoft. XMLHTTP ")
HttpClient. Open the "POST", "http://127.0.0.1/test.php", False
HttpClient. SetRequestHeader "content-type", "text/XML. Charset=gb2312 "
HttpClient. Send "f_name=aaa& F_code=123456
"


 
& lt; ? PHP
//force browser code
@ the header (' the content-type: text/HTML. Charset=gb2312 ');

//set the time zone
The date_default_timezone_set (" PRC ");


$s_name=trim ($_POST [' f_name ']);
$s_code=$_POST [' f_code];

Echo "user name". $s_name;
?>

CodePudding user response:

The post need to use the header
HttpClient. SetRequestHeader content-type ", "" application/x - WWW - form - urlencoded"

CodePudding user response:

Could you tell me how to solve the Chinese garbled?

CodePudding user response:

If all station, all with gb2312 encoding unified good, if use utf8, that in vb server-side transcoding

CodePudding user response:

& lt; html>
& lt; head>
& lt; Meta HTTP - equiv="content-type" Content="text/HTML. Charset=gb2312 "& gt;
& lt;/head>
& lt; body>
 & lt; ? PHP 
//force browser code
@ the header (' the content-type: text/HTML. Charset=gb2312 ');

//set the time zone
The date_default_timezone_set (" PRC ");


$s_name=trim ($_POST [' f_name ']);
$s_code=$_POST [' f_code];

Echo "user name". $s_name;
?> & lt;/body>
& lt;/html>

And pay attention to your PHP configuration, default_charset="gb2312"

CodePudding user response:

To learn, this is a VB.net code

CodePudding user response:

The third line the content-type change
 HttpClient. SetRequestHeader "content-type", "application/x - WWW - form - urlencoded; Charset=gb2312 "

CodePudding user response:

Online to find the URLEncode function
 Public Function URLEncode (ByVal strParameter As String) As String 
Dim s As String
Dim As Integer I
Dim intValue As Integer
Dim TmpData () As Byte
S=""
TmpData=https://bbs.csdn.net/topics/StrConv (strParameter vbFromUnicode)
For I=0 To UBound (TmpData)
IntValue (I)=https://bbs.csdn.net/topics/TmpData
If (intValue & gt;=48 And intValue & lt;=57) Or _
(intValue & gt;=65 And intValue & lt;=90) Or _
(intValue & gt;=97 And intValue & lt;=122) Then
S=s & amp; CRH (intValue)
Then ElseIf intValue=https://bbs.csdn.net/topics/32
S=s & amp; "+"
The Else
S=s & amp; "%" & amp; Hex (intValue)
End the If
Next I
URLEncode=s
End the Function

The fourth line of code to the
 HttpClient. Send "f_name=" & amp; URLEncode (" Chinese ") & amp; "& amp; F_code=123456 "
  • Related