Reputation: 558
I have a service that sends out text to an email entered after x number of days. I want to use cron, but I know that because my PHP script uses variables, this would not work. How can I change my PHP or do anything that would allow me to use cron (or even something else)? I just need something where it will store the emails then send them. I'm really new to PHP, so keep it simple please.
Here’s my code:
<?php
if(isset($_POST['email']))
{
$headers = "From: Memory Jet <[email protected]>\r\n";
$to_visitor = $_POST["email"];
$common_data = $_POST["message"];
mail($to_visitor, "Your Memory", $common_data, $headers);
}
?>
Upvotes: 1
Views: 131
Reputation: 3193
if you're wanting to store the data to transmit later, either using a database to store the info or writing it to a file would allow you to retrieve it.
If you need to potentially edit and manipulate the data later on, I'd recommend using a database.
I'd also recommend looking at http://www.tizag.com/phpT/ for some good, simple tutorials for PHP that really helped me when I first got going.
Upvotes: 1
Reputation: 3280
use argv array to read CLI params - http://php.net/manual/en/features.commandline.usage.php
if your script is named /bin/script.php
then if invoked as /bin/script.php xyz
the following:
$email = $argv[1];
will assign 'xyz'
to $email
.
just read doc I've provided - there's all you need
Upvotes: 2