Вы можете сделать это путем повторной загрузки всей страницы с помощью отправки формы или путем загрузки определенного содержимого страницы непосредственно на страницу без необходимости переходить от страницы к странице. Второй метод называется «AJAX» (асинхронный Javascript и XML). Вот два примера, каждый из которых указан.
Форма подачи заявки
form.php
<?php
function get_users(){
}
if(isset($_GET['get_users']))
{
get_users();
}
?>
...
<form method="get">
<input type="hidden" name="get_users">
<input type="submit">
</form>
AJAX подход
ajax_file.php
<?php
function call_me(){
// your php code
}
call_me();
?>
form.html
<html>
<head>
<script type="text/javascript">
function loadXMLDoc()
{
var xmlhttp;
if (window.XMLHttpRequest)
{
xmlhttp = new XMLHttpRequest();
}
else
{
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange = function()
{
if(xmlhttp.readyState == 4 && xmlhttp.status == 200)
{
// do something if the page loaded successfully
}
}
xmlhttp.open("GET","ajax_file.php",true);
xmlhttp.send();
}
</script>
</head>
<body>
<a href="#" onclick="loadXMLDoc()">click to call function</a>
</body>
</html>