<!DOCTYPE html>
<html>
<title>
Test page
</title>
<?php
$uri=$_SERVER['REQUEST_URI'];
?>
<a href='#' onclick='<?php file_put_contents('feedback.txt',$uri.' ST'.'I understand this'.PHP_EOL , FILE_APPEND | LOCK_EX)?>'>I understand this </a>
<button onclick='<?php file_put_contents('feedback.txt',$uri.' ST'.'I don\'t understand this'.PHP_EOL , FILE_APPEND | LOCK_EX)?>'>I don't understand this </button>
In the above html/php code, I have both a button and a link that should write to a file when clicked. When I was experimenting with it, however, I found that the code ran every time I refreshed the page, is there any way to prevent this?