help
i want someone to be able to write an email and choose a time and date for it to be sent can someone help me on where to start.
here is what i need in my form
E-Mail to sent to:
Message:
Date of time to be sent :
i want to have a slider for the user to set a date,
i want this to be inserted into a database which will send the email to the recipient on the time and date they specified.
Can someone just give me some help on where to start.
so far ive got this
<?php
include "conninfo.php";//connects to my database
$timenow = time();
$query = mysql_query("SELECT * FROM send WHERE time='$timenow';");
while($query=mysql_fetch_array($query);) {
$to = "samuelrweast@hotmail.com";
$email = $query['email'];
$message = $query['message'];
$subject = = $query['subject'];
$time = = $query['time'];
$headers = //Include header info here..
mail($to, $email, $subject, $message, $time, $headers, -$from);
}
?>
//this is the form
<form method="POST" action="insert.php">
E-Mail:
<input type="text" name="email" id="email" size="19"><br>
<br>
<br>
Message:<br>
<textarea rows="9" name="message" id="message" cols="30"></textarea><br>
<br>
Subject:
<input type="text" name="subject" id="subject" size="19"><br>
<br>
Message to be sent after :
Days: <br>
<input type="text" name="day" id="min" size="10"><br>
<br>
Hours: <br>
<input type="text" name="hrs" id="hrs" size="10"><br>
<br>
Minutes: <br>
<input type="text" name="min" id="min" size="10"><br>
<br>
<input type="submit" value="Submit" name="submit">
</form>
//and this is the insert.php
<?php
include "conninfo.php";
$email = $_POST["email"];
$message = $_POST["message"];
$subject = $_POST["subject"];
$min = $_POST["min"];
$hrs = $_POST["hrs"];
$day = $_POST["day"];
if($min == 0) { $min='1'; }
if($hrs == 0) { $hrs='1'; }
if($day == 0) { $day='1'; }
$date = 60*$min*$hrs*$day;
$time = time() + $date;
$query = "INSERT INTO send (email, message, subject, time) VALUES ('$email', '$message', '$subject', '$time')";
mysql_query($query) or die('Error, insert query failed');
?>
set email
Moderator: General Moderators
Re: set email
Look into "cron". You'll have to set up a PHP script to run every minute. It looks in the database for any emails it's supposed to send (and sends them).
The slider will take some JavaScript work, but you can probably find something out there that's premade.
For both of those, Google is your friend.
The slider will take some JavaScript work, but you can probably find something out there that's premade.
For both of those, Google is your friend.
Re: set email
ok thanks for the reply ive been googling cron tab
and ive got to this ive checked and my server is cgi.
i dont get this part.
If the answer to the question above is “CGI” then you need to add a line to your PHP script. It has to be the first line of your script and must contain your server’s PHP executable location:
#!/usr/local/bin/php -q
what is my server’s PHP executable location how do i acess this so i just have the cron tab running in a seperate file and the server keeps acessing it it doesnt have to be in the index.
any help
and ive got to this ive checked and my server is cgi.
i dont get this part.
If the answer to the question above is “CGI” then you need to add a line to your PHP script. It has to be the first line of your script and must contain your server’s PHP executable location:
#!/usr/local/bin/php -q
what is my server’s PHP executable location how do i acess this so i just have the cron tab running in a seperate file and the server keeps acessing it it doesnt have to be in the index.
any help
Re: set email
Crash course on cron:
There's a program running in the background. Every minute it looks in a specific file for a list of commands to run and when to run them. It looks at the current time, decides whether the command should run, and makes it do so if necessary.
You put an entry into this file that says "run this command every minute". That command can be
That tells PHP to run your file. 99% likely: you don't need to know the path to PHP because the server knows already.
Since you're explicitly telling PHP to run this file it won't need the shebang (the #! at the beginning).
There's a program running in the background. Every minute it looks in a specific file for a list of commands to run and when to run them. It looks at the current time, decides whether the command should run, and makes it do so if necessary.
You put an entry into this file that says "run this command every minute". That command can be
Code: Select all
php -f /path/to/file.phpSince you're explicitly telling PHP to run this file it won't need the shebang (the #! at the beginning).
Re: set email
can anyone show me an example of a crontab script as im finding this confusing anything with a simple echo statement or something so i can simply see a working script.
sorry finding it hard to find any good step by step tutorials on crontab or cronjob.
ive emailed my hosting and they have said that they cant garantee the cronjob this is the reply.
"You should only create CRON jobs on the understanding that they are unsupported, and no reliability can be made upon their timings or execution. This is to ensure the management of resources for all users on our shared hosting servers."
is this true with all hosting packages?
any help pls.
sorry finding it hard to find any good step by step tutorials on crontab or cronjob.
ive emailed my hosting and they have said that they cant garantee the cronjob this is the reply.
"You should only create CRON jobs on the understanding that they are unsupported, and no reliability can be made upon their timings or execution. This is to ensure the management of resources for all users on our shared hosting servers."
is this true with all hosting packages?
any help pls.