title: Sending data to php from windows phone
body: <p>I need to send some data from windows phone 7 to php page through POST method, I have the following code at wp7 side</p>
  
  <pre><code>    public void SendPost()
      {
          var url = "http://localhost/HelpFello/profile.php";
  
          // Create the web request object
          HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(url);
          webRequest.Method = "POST";
          webRequest.ContentType = "application/x-www-form-urlencoded";
  
          // Start the request
          webRequest.BeginGetRequestStream(new AsyncCallback(GetRequestStreamCallback), webRequest);
          MessageBox.Show("data sent");
      }
  
      void GetRequestStreamCallback(IAsyncResult asynchronousResult)
      {
          HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
          // End the stream request operation
          Stream postStream = webRequest.EndGetRequestStream(asynchronousResult);
  
          // Create the post data
          // Demo POST data 
          string postData = "user_id=3&amp;name=danish&amp;email_id=mdsiddiquiufo&amp;password=12345&amp;phone_Number=0213&amp;about_me=IRuel2&amp;rating=5";
  
          byte[] byteArray = Encoding.UTF8.GetBytes(postData);
  
          // Add the post data to the web request
          postStream.Write(byteArray, 0, byteArray.Length);
          postStream.Close();
  
          // Start the web request
          webRequest.BeginGetResponse(new AsyncCallback(GetResponseCallback), webRequest);
      }
  
      void GetResponseCallback(IAsyncResult asynchronousResult)
      {
          try
          {
              HttpWebRequest webRequest = (HttpWebRequest)asynchronousResult.AsyncState;
              HttpWebResponse response;
  
              // End the get response operation
              response = (HttpWebResponse)webRequest.EndGetResponse(asynchronousResult);
              Stream streamResponse = response.GetResponseStream();
              StreamReader streamReader = new StreamReader(streamResponse);
              var Response = streamReader.ReadToEnd();
              streamResponse.Close();
              streamReader.Close();
              response.Close();
  
          }
          catch (WebException e)
          {
              MessageBox.Show(e.ToString());
          }
      }
  </code></pre>
  
  <p>and following on my localhost, to send the data to database</p>
  
  <pre><code>&lt;?php
  require_once("constants.php");
  $user_id = $_POST['user_id'];
  $name = $_POST['name'];
  $email_id = $_POST['email_id'];
  $password = $_POST['password'];
  $phone_number = $_POST['phone_number'];
  $about_me = $_POST['about_me'];
  $rating = $_POST['rating'];
  
  
  $query="INSERT INTO profile(User_ID,Name,Email_ID,password,Phone_Number,About_Me,Rating) VALUES ({$user_id},'{$name}','{$email_id}','{$password}',{$phone_number}, '{$about_me}' , {$rating})";
  mysql_query($query,$connection);
  mysql_close($connection);
  ?&gt;
  </code></pre>
  
  <p>When I run the code I have no errors it means code is working fine, but no data is inserted in the database.</p>