简体   繁体   English

从服务器触发PHP脚本

[英]Trigger PHP scripts from server

Fairly new to PHP but in the middle of building an admin panel for a booking system. PHP相当陌生,但在为预订系统构建管理面板的过程中。 Just a question for the future. 只是未来的问题。

Lets say a user has not confirmed their booking. 假设用户尚未确认其预订。 When 20 days remain say until their start date I would like a PHP to trigger that sends them out an email and alters some text on their account. 剩下20天的时间说,直到他们的开始日期,我想要一个PHP触发它向他们发送电子邮件并更改他们帐户上的一些文本。

All this I know how to do if I bring up a page that queries on those basise. 如果我打开以此为基础的查询页面,我将知道该怎么做。

How would I just get the server to do that automatically. 我将如何让服务器自动执行此操作。 So rather than me or the user go to their booking and it to trigger the PHP script for the server to simply execute it at a certain time anyway. 因此,而不是由我或用户去预订,而是触发服务器的PHP脚本以在特定时间简单地执行它。

Any ideas? 有任何想法吗?

Marvellous 奇妙

Cron. 克龙。 What you want is a daily cron job that runs a php script. 您想要的是运行php脚本的日常cron作业。

On most hosting control panels there's a cron tool somewhere. 在大多数主机控制面板上,某处都有cron工具。 You just need to set up the command for it to do and when do to it. 您只需要设置执行命令和执行命令的时间即可。 It would wind up something like 0 0 * * * * /fullpath/to/php /fullpath/to/script.php to run the script every day at midnight. 它将每天结束,例如0 0 * * * * /fullpath/to/php /fullpath/to/script.php以在每天午夜运行脚本。

If the script is web accessible, there are free web cron services, where you can set them up to access the script whenever you want. 如果脚本可以通过Web访问,则可以使用免费的Web Cron服务,您可以在其中设置它们以随时访问脚本。 Of course, you'd want some extra security on it in that case. 当然,在这种情况下,您需要一些额外的安全性。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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