Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I call php script each time html file loads?

Tags:

html

php

I have php script that counts web site visits. I need to call that script each time my html page loads.

How do I do that?

like image 328
user1007632 Avatar asked Dec 31 '25 13:12

user1007632


1 Answers

If it's a PHP page, you can include/require a page in to another PHP page using require or include see include and require documentation

require("counting_script.php");
// or
include("counting_script.php");

If it's a purely HTML file, then you could consider using an iFrame to load your other page see tutorial

<iframe src="page_counter.php"></iframe>

Or if you know jQuery, you could make an ajax call (using jQuery) to your counting page. See documentation

$.get('page_counter.php', function(data) {
  alert('Counter page was called');
});
like image 56
Luke Avatar answered Jan 02 '26 04:01

Luke