简体   繁体   English

操纵time()函数以允许发送电子邮件

[英]Manipulating the time() function to allow email to be sent out

I have written a piece of code that allows an email to be sent out to all users that haven't logged in for a certain amount of time. 我编写了一段代码,该代码允许将电子邮件发送给一定时间内未登录的所有用户。

The HTML is: HTML是:

<select name="criteria">
    <option value="14"<?php if("14" == $form->value("criteria")){ echo 'selected="selected"'; }?>>14 days</option>
    <option value="28"<?php if("28" == $form->value("criteria")){ echo 'selected="selected"'; }?>>28 days</option>
    <option value="90"<?php if("90" == $form->value("criteria")){ echo 'selected="selected"'; }?>>3 months</option>
    <option value="180"<?php if("180" == $form->value("criteria")){ echo 'selected="selected"'; }?>>6 months</option>
    <option value="365"<?php if("365" == $form->value("criteria")){ echo 'selected="selected"'; }?>>1 year</option>
</select>

This is then received in another file and the following code takes over 然后将其接收到另一个文件中,以下代码将接管

$time = time() - ($criteria * 0 * 0 * 0);
$q = $admindb->getReminderCustomerEmail($time);

The database query is as follows: 数据库查询如下:

function getReminderCustomerEmail($time){
    global $database;
    $q = "SELECT email, title, forename, surname FROM ".TBL_USERS." WHERE last_logged <= '$time'";
    return mysql_query($q, $database->myConnection());
}

The idea is that if you select 14 days, all users that haven't logged in in the last 14 days will be mailed. 这样做的想法是,如果您选择14天,则将邮寄过去14天内未登录的所有用户。

At the moment, this isn't happening, it seems to just message all users. 目前,这还没有发生,似乎只是向所有用户发送消息。

I think the error must be in the line 我认为错误一定在

$time = time() - ($criteria * 0 * 0 * 0);

Any ideas? 有任何想法吗? Thanks 谢谢

Any number times zero is always zero. 任何数字乘以 总是零。

Are you looking for ($criteria * 86400) perhaps (to get days) then subtract that value from time() ? 您是否正在寻找($criteria * 86400) ,然后从time()减去值?

You can also use strtotime : 您也可以使用strtotime

strtotime('-' + $criteria + ' day',time());

Wouldn't 0 be subtracted from time() all the time? 难道不总是从time()中减去0吗? $criteria is being multiplied by 0... $ criteria被乘以0 ...

A silly question: 1000 * 0 = ?? 一个愚蠢的问题:1000 * 0 = ??

That's right, it is 0 是的,它是0

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

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