0

I am a novice with html and PHP, but I have a fairly simple requirement. I have tried a number of different approaches, but none of them meet my needs.

The page should do the following:

  1. Display some text, a picture, and the date-timestamp of a file from the server (this works Display a button.
  2. If the user clicks the button, perform php that modifies files on the server. (This works, but see problem below)
  3. Refresh the page every 30 seconds (to display effects of a server process that updates the picture and date-timestamp mentioned in 1 above).

Following is what I am currently trying in g_test_02.php. The problem is that when I load the page in a browser, when it refreshes from the header, it performs the even though I have not clicked the button. I can see this viewing the files on the server.

What am I doing wrong?

Thanks

<html>
<body>
<head>
<META HTTP-EQUIV="REFRESH"
CONTENT="30">
</head>

<?PHP
Do some php to display the date-timestamp of a file on the Unix server
?>

Display some html text and a picture

<script>
function myFunction() {
<?php
Do some php to modify files on the server
?>
        location.reload();
}
</script>

<button onclick="myFunction()">Verify door</button>

</body>
</html>
JimR
  • 473
  • 2
  • 11
  • That would be because `PHP` is **server side** and runs before the `HTML/CSS/JS` as that's **client side**. You'll need to look at using ajax. – Darren Jul 11 '14 at 03:42

1 Answers1

-1

Try this:

<html>
<body>

<script>
function myFunction() {
    setInterval(function(){alert("Hello")}, 5000);
}
</script>

<button onclick="myFunction()">Verify door</button>

</body>
</html>
Sanjay Kumar N S
  • 4,653
  • 4
  • 23
  • 38