none
VALUE SENT FROM POST NOT SHOWING IN PHP VB RRS feed

  • Question

  • I'm trying to senD values to PHP from visual Studio, then insert these values to mysql database but values inserted as blanks

    i found this code 

     

     Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click

    Dim Username = txtname.text
            Dim PostData = "user_name=" & Username
            Dim request As WebRequest = WebRequest.Create("http://xxx.com/xxx/check.php")
            request.Method = "POST"
            Dim byteArray As Byte() = Encoding.UTF8.GetBytes(PostData)
            request.ContentType = "application/x-www-form-urlencoded"
            request.ContentLength = byteArray.Length
            Dim dataStream As Stream = request.GetRequestStream()
            dataStream.Write(byteArray, 0, byteArray.Length)
            'dataStream.Close()
            Dim response As WebResponse = request.GetResponse()
            dataStream = response.GetResponseStream()
            Dim reader As New StreamReader(dataStream)
            Dim responseFromServer As String = reader.ReadToEnd()
            reader.Close()
            dataStream.Close()
            response.Close()
            MsgBox(responseFromServer)

    End Sub

     **** my php file 

    <?php 

    $username=$_POST['user_name'];

    echo "username is :".$username;

    ?>

    username value sent as is blank 

    how can i fix it ?



    • Edited by RGHAREEB Tuesday, February 26, 2019 2:13 PM
    Tuesday, February 26, 2019 2:12 PM

All replies