I wanted a php script to execute when the user press the button. In my html file i used a jquery script
<script>
        $(document).ready(function(){
            $(".btn").click(function(){
                var firstname = $("#firstname").val();
                var lasname = $("#lastname").val();
                var dataNames = { 'firstnameVal' : firstname};
                $.post("SaveNames.php",dataNames,function()
                       {
                    alert("hi");
                });
            });   
        });                
    </script>
and
<input type="text" id="firstname" name="firstname">
<input type="text" id="lastname" name="lastname">
in my php file i used some help from here
<?php
if (isset($_POST["fistname"]))
{
        $firstname = $_POST["firstname"];
        $SavedNames = fopen("Names.txt","w");
        $NamesText = "Its Work!";
        fwrite($SavedNames,$NamesText);
        fclose($SavedNames);
}
?>
The problem is the fopen() doesn't work (don't create file) and I tried to create the file to check if fwrite() works but it's also didn't worked.
I use localhost wamp server.
 
     
     
     
    