1

I have code in VB.net code where we are entering a php url

IEPostStringRequest "www.example.com/call.php?" & Str1,

Sub IEPostStringRequest(URL, FormData)
    On Error Resume Next
  'Create InternetExplorer
 Set WebBrowser = CreateObject("InternetExplorer.Application")
  'You can uncoment Next line To see form results As HTML
  WebBrowser.Visible = False

  'Send the form data To URL As POST request
  Dim bFormData() As Byte
  ReDim bFormData(Len(FormData) - 1)
  bFormData = StrConv(FormData, vbFromUnicode)
  WebBrowser.Navigate URL, "_Self", , bFormData, _
    "Content-Type: application/x-www-form-urlencoded" + Chr(10) + Chr(13)

  Do While WebBrowser.busy
'    Sleep 100
    DoEvents
  Loop

  WebBrowser.Quit
End Sub

Now i want to fetch these parameters value in this www.example.com/call.php page. when i am tried this $_POST['str']; but getting nothing.

Kindly help me. Thank you in advance.

Professor Abronsius
  • 33,063
  • 5
  • 32
  • 46
geetika
  • 21
  • 9

2 Answers2

0

Use $_GET['str'].

For this to work, make sure your variable starts with 'str='. Otherwise, just do a print_r($_GET) in your php and get the names from that

If you are concatenating a string to the URL, you are not sending it as POST data, but rather as GET data.

To be able to send them as POST fields, you could use curl, if strictly necessary. For that, try to adapt this to VB: POST data to a URL in PHP

Community
  • 1
  • 1
Alex Tartan
  • 6,736
  • 10
  • 34
  • 45
  • $_GET , $_REQUEST already use it but still getting nothing and Array() – geetika Jul 25 '15 at 13:13
  • Can you post an example of `Str1`? I believe you are not assigning the value to a parameter name like call.php?str=Str1 (in the case Str1 does not start with 'str=') – Alex Tartan Jul 25 '15 at 13:15
0

using get method ($_GET['str']) the data passing will be vulnerable.

it is better to send data via POST method.

example:

---------------------------------VB.NET PART-------------------------------

 Dim request As HttpWebRequest = HttpWebRequest.Create("http://xxx/xxx/test.php")
 request.Method = "POST"
 request.Proxy = Nothing

 Dim bytedata As Byte() = Encoding.UTF8.GetBytes("name=Piyush")
 request.ContentType = "application/x-www-form-urlencoded"
 request.ContentLength = bytedata.Length

 Dim dataStream As Stream = request.GetRequestStream()
 dataStream.Write(bytedata, 0, bytedata.Length)
 dataStream.Close()

---------------------------------PHP PART-------------------------------

$name= isset($_POST["name"]) ? ($_POST["name"]):"";
echo $name;

this will pass parameter to PHP file.