I’m trying to create a service that some will enter a message or reminder then it will be stored and sent after an x amount of days. I’m not sure on how to store it then send it. I wanted to use cron, and because it’s using an email variable I will have to use a database. I am very new to PHP, so I dont know how i could do this at all. I’ll put up my php code and I wanted to know what to do so the email and message would be stored and then sent. Here’s my php code:
<?php
if(isset($_POST['email']))
{
$headers = "From: Memory Jet <your_company@example.com>\r\n";
$to_visitor = $_POST["email"];
$common_data = $_POST["message"];
mail($to_visitor, "Your Memory", $common_data, $headers);
} ?>
How could I implement a mySQL database with this code? What would I have to do?
Thanks so much! -Ben
Your DB table would basically contain this:
You’d have a SINGLE php script that would pull up any messages whose “date_to_send” is in the past, and have NOT been sent already:
You’d loop over these results, send any messages that need to go, and then update the records to indicate they’d been sent.
Note that
fromis almost guaranteed to be a reserved word in your database. This “code” is just an example, and shouldn’t be cut/pasted literally.