简体   繁体   中英

How to run a php file in the background without actually opening the php file? (Time based event)

<?php

session_start();

$con = mysqli_connect('localhost', 'root');

mysqli_select_db($con, 'id12887901_visitor');

$query = "select * from curvis1 order by id desc limit 1";
$result = mysqli_query($con, $query);
$row = mysqli_fetch_array($result);

date_default_timezone_set('Asia/Hong_Kong');
$today = date("H:i:s");
  echo $today;  

if ($today == $row['end_at']){
  $msg = "Visitor No.1 pass has expired.";
  $reg = "insert into msg(comment) values('$msg')";
  mysqli_query($con, $reg);
  echo "WTF";

} else  {
  echo "LOL";

}


?>

I want it to run in the background. I've head of using ajax but alas I have not found an ajax solution in this. Any feedback will be appreciated thank you.

This is for a notification.

How do i call the server by ajax and asking frequently if there's any changes etc.

Cron did the job for me after learning it! sorry for the dumb question guys.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM