First I want to make sure you understand that php is ran on the server side, the browser can not run php. As such to run a php script you must make an http request (load a page).
In your code you need to first set the "action' and "method" attributes of the <form> tag.
<form action="yourpage.php" method="post">
<p align="center">
<input type="button" value="ارسل ختمة" name="submit1">
</p>
</form>
And Second you need to wrap your php in an "if" to look to see if $POST['submit1'] is set.
<?php
if (isset($_POST['submit1'])) {
// the code to store the sum in a file
}
?>
Next your code is bit off. Your while loop looks to be looping through every character in the file and that is fine for 0-9 values but what happens when you reach 10 and up. I think you would be better off removing the while loop and replacing the "fgetc" with "file_get_contents".
Like this
$var=fopen("count.txt",'r');
$sum=0;
$char1=file_get_contents($var);
$sum=$sum*10;
$sum=$sum+$char1;
$sum=$sum/10;
$sum++;
print "$sum";
fclose($var);
$var=fopen("count.txt",'w');
fwrite($var,$sum);
fclose($var);
Lastly I am not sure what value you are trying to reach but your math is bit odd.
like this line
$sum=$sum*10;
Will equal 0 so it isn't needed
Then if that line isn't need this line
$sum=$sum+$char1;
could be
$sum=$char1;
Next this line
$sum=$sum/10;
makes your value a decimal value so if "char1" is 2 the result is .2 or if "char1" is 55 the result is 5.5
And then
$sum++;
adds 1 to the value.
So if your "count.txt" had a value of 1 the end result is 1.1. Now that could be the result you want but I suspect it isn't the result you want. As the next time you run your above code against the files value you will get a result of 1.11. the next time it will be 1.111 and the next time it will be 1.1111, your value will never reach 2.