Jump to content

Reminder System


cdoggg94

Recommended Posts

I would like to set up a reminder system where on a certain day of the users choice, they are sent an email to remind them of a specific thing.

 

What I have now is a "To Do" list.

 

here:

<?php

$today = date("m.d.y");

?>

<table border="0">
  <tr>
    <td align="center">
      <span style="font-size:14px;"><?php echo $today2; ?></span><br /><br />
      </td>
    </tr>
  <tr>
    <td>
      <span style="font-size:14px; font-weight:bold;">To Do List:</span>
      <ul>
        <?php do{ ?>
          <li>
            <?php echo $row_toDO['toDo_info'] ;?>  <br /><a href="index.php?toDo_id=<?php echo $row_toDO['toDo_id']; ?>">Delete</a><br /><br />
            
            
            </li>
          <?php } while ($row_toDO = mysql_fetch_assoc($toDO)); ?>
        </ul>
      </td>
    </tr>
  
</table>

You add things to this list with this form:


<table border="0" align="center">
  <tr>
    <td align="center" style=" font-size:14px;">Add to To Do List</td>
    </tr>
  <form action="<?php echo $editFormAction; ?>" method="POST" id="toDo" name="toDo">
    <tr>
      <td align="center"><textarea name="info" cols="26" rows="5"></textarea>
        </td>
      </tr>
    <tr>
      <td align="center">
        <input name="id" type="hidden" value="" />
        <input name="user" type="hidden" value="Dave" />
        <input type="submit" value="" class="imgClass3" />
        </td>
      <input type="hidden" name="MM_insert" value="toDo" />
      </tr>
    </form>
</table>

My idea is to add a date section to the form, so that if they would like to be reminded on say "June 10, 2013" They select June, 13, 2013...etc..

Now...my issue now is: Where would I make a script to ensure they get this reminder even if you are not using a specific page?
 

My thought process is telling me that the script structure should be something like, 

if (toDoDate == todaysDate) {
       

      email reminder

}

 

Am I even close here ?

 

Link to comment
Share on other sites

If you would follow your logic, the email would only be sent if you load the page, which is not really the best. I dont need a reminder if I am already viewing the reminders.

I'm sure he meant the system would check for *all reminders* anytime anyone viewed *any page*. This can kinda be used to executed events at given intervals if you have a reliable source of traffic. Really though, it's not at all reliable.

Link to comment
Share on other sites

I'm sure he meant the system would check for *all reminders* anytime anyone viewed *any page*. This can kinda be used to executed events at given intervals if you have a reliable source of traffic. Really though, it's not at all reliable.

 

Sure, I get that, but that its still no guarentee you will actually get reminded, as you also point out.

Link to comment
Share on other sites

I am still not 100% sure where to put the Cron Job.  If say the "To Do" list is on the index page, would I be adding the script to that page ?

 

I am looking at this right now : http://www.thesitewizard.com/general/set-cron-job.shtml and it it showing me basic format, but I am still a little confused as how to use it.

Does anyone know of a better example link?

Link to comment
Share on other sites

Well, you can set up the cronjob to run, say, once a day for now, and it gives the user an overview of the reminders he has today.

 

You shouldnt adapt the cronjob to the user. Just embrace the fact that you cant get it right on the minute, or even on the hour.

Link to comment
Share on other sites

Just embrace the fact that you cant get it right on the minute, or even on the hour.

 

Not true. You can set the cronjob to run every hour if you wanted. If you have lots of reminders then its obviously going to take longer with just a single server, but you can still do it. Think of google calendar (I'm not saying they use a cron but its a similar concept), they dispatch reminders to the minute and may use a cluster server for carrying out the task.

 

Crontab is a program used to set up new cronjobs that are executed by the cron daemon on a linux machine (usually a server else the whole concept would be pretty pointless as normal computers are turned off regularly).

 

What it executes is entirely up to you; you could execute a python script if you wanted, not just php. In your case you're going to be executing a PHP script that connects to a database, retrieves all the reminders for a given day, and sends an email to the user with a list of events. You could trigger the cron to go off in the early hours of the morning every day:

0 4 * * * php /home/account/private/crons/dispatchReminders.php

For a guide on the crontab and how to use it you can go to http://crontab.org/. The tutorial you already have simplifies it quite a bit and abstracts the main content.

 

The script you execute is completely separate from the script you use to display the reminders as they have two separate purposes. One is to dispatch reminders, the other is to display reminders to an end user using HTML in a web browser (just an example).

Edited by cpd
Link to comment
Share on other sites

I get that you can set a cronjob every hour if you see that interval fit. I was merely trying to explain that setting a cronjob on a specific time set by the user is not the way that is supposed to work and I was indeed a little short sighted in not mentioning that every hour is an option, but you wont get it down to the minute. You COULD set it to the minute, but the smaller the interval is the bigger the server is you will need. Google calendar can easily support a minute support, simply because Google is Google.

 

Thanks for pointing that out though.

Edited by DaveyK
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.