Tengo el siguiente codigo, no llega el email, quiza el campo de la tabla no es la correcta
guarda el campo de esta forma "20151029" creo que deberia ir de esta forma "2015-10-29"
aun que soy de la idea que envie con "Y-m-d H:i:s" "2015-10-29 21:30:45"
para que envie con una fecha y hora supongo que es mejor..
por que no llega el email?
en caso se deba usar cron job como lo integraria?
se podria integrar en este codigo? y como seria?
o sea
"reminder_date datetime DEFAULT NULL,"
Código PHP:
<?php
include('database.inc.php'); // Our database connectivity file
if($_POST['step'] != '1')
{
?>
<html>
<head><title>Add Reminders</title></head>
<body>
<form name="setup_reminder" action="reminder_setup.php" method="post">
<table border='0' align='center'><tr><td>Event:</td><td>
<input name="reminder_name" type="text" maxlength="255" />
</td></tr><tr><td>Description</td><td>
<textarea name="reminder_desc" rows="5" /></textarea>
</td></tr><tr><td>Trigger Date</td><td>
<select name="reminder_year">
<?php
$current_year = date("Y");
for($counter=$current_year;$counter<=$current_year+2;$counter++)
{
echo("\n<option>$counter</option>");
}
?>
</select>
<select name="reminder_month">
<?php
for($counter=1;$counter<=12;$counter++)
{
if($counter < 10)
$prefix = "0";
else
$prefix = "";
echo("\n<option>$prefix$counter</option>");
}
?>
</select>
<select name="reminder_date">
<?php
for($counter=1;$counter<=31;$counter++)
{
if($counter < 10)
$prefix = "";
echo("\n<option>$prefix$counter</option>");
}
?>
</select>
</td></tr><tr><td> </td><td>
<input name="step" type="hidden" value="1" />
<input name="submit" type="submit" value="add" />
</td></tr></table>
</form>
<?php
}
else
{
$error_list = "";
$todays_date = date( "Ymd" );
$reminder_date = $_POST['reminder_year'].$_POST['reminder_month'].$_POST['reminder_date'];
if( empty($_POST['reminder_name']) )
$error_list .= "No Reminder Name<br />";
if( !checkdate( $_POST['reminder_month'], $_POST['reminder_date'], $_POST['reminder_year'] ))
$error_list .= "Reminder Date is invalid<br />";
else if( $reminder_date <= $todays_date )
$error_list .= "Reminder Date is not a future date<br />";
if( empty( $error_list ) )
{
// No error let's add the entry
mysql_query( "INSERT INTO reminder_events(`reminder_name`, `reminder_desc`, `reminder_date`) VALUES('".addslashes($_POST['reminder_name'])."', '".addslashes($_POST['reminder_desc'])."', '".addslashes($reminder_date)."')" );
// Let's go to the Reminder List page
Header("Refresh: 1;url=reminder_list.php");
echo <<< _HTML_END_
Reminder Added, redirecting ...
_HTML_END_;
}
else
{
// Error occurred let's notify it
echo( $error_list );
}
}
//$todays_date = date( "Ymd" );
?>
</body>
</html>
Código PHP:
<?php
include('database.inc.php'); // Our database connectivity file
// Values you need set
$number_of_days_before = 1;
$email = "[email protected]"; // Aqui el email
$reminder_details = "";
$todays_date = date( "Ymd" );
$year = substr($todays_date, 0, 4);
$month = substr($todays_date, 4, 2);
$date = substr($todays_date, 6, 2);
$trigger_date = date("Ymd", mktime (0,0,0,$month,$date-$number_of_days_before,$year));
$result = mysql_query( "SELECT * FROM reminder_events WHERE reminder_date <= $trigger_date ORDER BY reminder_date ASC" );
$nr = mysql_num_rows( $result );
while( $row = mysql_fetch_array( $result ) )
{
$year = substr($row["reminder_date"], 0, 4);
$month = substr($row["reminder_date"], 4, 2);
$date = substr($row["reminder_date"], 6, 2);
$reminder_date = date("M j, Y", mktime (0,0,0,$month,$date,$year));
$reminder_details .= "Event: ".$row["reminder_name"]."\n";
$reminder_details .= "Date: ".$reminder_date."\n";
$reminder_details .= $row["reminder_desc"]."\n\n";
}
mysql_free_result( $result );
if( !empty( $nr ) )
{
// Send out Reminder mail
$mailheader = "From: Reminder System <$email>\nX-Mailer: Reminder\nContent-Type: text/plain";
mail("$email","Reminder","$reminder_details","$mailheader");
// Delete the sent reminders
mysql_query("DELETE FROM reminder_events WHERE reminder_date <= $trigger_date" );
}
?>
TABLA
Este DB no me deja insertar
Código HTML:
CREATE TABLE reminder_events ( reminder_id bigint(20) unsigned NOT NULL auto_increment, reminder_name varchar(255) NOT NULL default '', reminder_desc text, reminder_date varchar(8) unsigned NOT NULL default '0', PRIMARY KEY (reminder_id), KEY reminder_id (reminder_id) ) TYPE=MyISAM;
Código HTML:
CREATE TABLE IF NOT EXISTS `reminder_events` ( `reminder_id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `reminder_name` varchar(100) NOT NULL, `reminder_desc` text NOT NULL, `reminder_date` varchar(100) NOT NULL, PRIMARY KEY (`reminder_id`) ) ;