Question: okay good evening 

i been having problems recieving data from http request from a C++ program

I use `Wininet` 

```
InternetOpenA()
InternetConnect()
HttpOpenRequest()
HttpSendRequest()

```

now the good news is it sends the program to the php file, now no worries all work fine there 

when i do a code like this to get the POST data 

```
<?php
$data = file_get_contents(php://input);
$fp = fopen("log.txt","a+");
fwrite($fp,$data);
fclose($fp);
?>

```

it gets the data and saves to text file. but when i do the following

```
<?php
$data = urldecode($_POST['info']);
$fp = fopen("log.txt","a+");
fwrite($fp,$data);
fclose($fp);
?>

```

it just creates the log.txt and doesnt save any data inside it. Started to think this is a php problem, but every thing i tried just fails... what could be wrong?

Answer: 
You can disable the button after it is clicked. 

Only issue is if you use ASP.Net MVC client-side validation, you want to disable it ***only after client-side validation is successful***. ***Otherwise, button will be disabled forever*** if user clicks on the button without entering anything. 

```
@using (Html.BeginForm("Login", "Account",
   new { ReturnUrl = ViewBag.ReturnUrl },
   FormMethod.Post, new {  role = "form", autocomplete = "off" }))
{
   @Html.AntiForgeryToken()
   ...
   <div class="form-group">
     <button id="btnSubmit" type="submit" value="Sign In" 
         class="btn btn-primary btn-block">Sign In</button>
   </div>
}

<script type="text/javascript">
    $(function () {    
        $("form").data("validator").settings.submitHandler = function (form) {
            $("#btnSubmit").html("<i class=\"fa fa-spinner fa-pulse\"></i> Signing In...").prop('disabled', true);
            form.submit();
        };
    });
</script>

```

[![enter image description here](https://i.stack.imgur.com/RmrEX.png)](https://i.stack.imgur.com/RmrEX.png)
You can disable the button on click with jQuery like this:

```
$('#ButtonToTriggerId').click(function(){ $(this).prop('disabled',true)});

```

But the correct is create a progress bar or a loading gif to "entretain" the user.

If you are using JQuery ajax you can do like this:

```
$('#ButtonToTriggerId').click(function(){
   $(this).prop('disabled',true);
   $.ajax({//call jQuery ajax
       type: 'Post',//Your ActionResult HttpMethod
       url:  '@Url.Action("Login","ControllerName")/?returnUrl='+"%2F",//send the return URl to the ActionResult Mehod
       data: JSON.stringify($('#myForm')),//send the form to the ActionResult  Method
       done: function(){
           $('#ButtonToTriggerId').prop('disabled',false);//enable when the ajax request ends
       }

    })
});

```