I just want to create a button that when I click on it, it will read a text file I have in the same directory as this php file. I create this code but when I click at ethe button nothing happens.. Did I make something wrong? Can someone help me because I a beginner at php and javascript. Thanks,
<!DOCTYPE html>
<html>
<body>
<button onclick="read()">Click me</button>
<p id="demo"></p>
<script>
function read(){
$myfile = fopen("lala.txt", "r") or die("Unable to open file!");
echo fread($myfile,filesize("lala.txt"));
fclose($myfile);
}
</script>
</body>
</html>