Send autoresponder if sendDate matches today's date (PHP)

Hi,

Basically what I am trying to achieve here is if sendDate (select by user on the form) matches today’s date, send out the autoresponder automatically.

I am still learning PHP MySQL and here are my code:

HTML Form (i am using datetimepicker javascript):
When would you like
the card to be sent?
Pick a date

When submit, the date store in MySQL.

Here is my process.php code (for the autoresponder):

	[i]// Send autoresponder
	$template = 'emailer/autoresponder.html';
	$fd = fopen($template,"r");
	
	$sdate = date("M-d-Y");
	
	$query="SELECT ID,email,sendDate FROM test WHERE sendDate='".$sdate."'";
	$result=mysql_query($query) or die ($query . "<br />" . mysql_error()); 
	
	if($sdate==$sendDate)
	{
	
	$TO = $_POST['rvar_card_email'];
	$SUBJECT = "Mikey Network Donation - E-Card";
	$FROM = "[email protected]";
	
	$HEADER = 'MIME-Version: 1.0' . "\r\n";
	$HEADER .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	$HEADER .= "From: $FROM";
	$MESSAGE = fread($fd, filesize($template));
	
	$original = array("{rvar_card_description}", "{rvar_card_message}", "{rvar_card_signature}");
	$replace = array($rvar_card_description, $rvar_card_message, $rvar_card_signature);
	$MESSAGE = str_replace($original,$replace, $MESSAGE);
	
	mail($TO,$SUBJECT,$MESSAGE,$HEADER);

	fclose($fd);
	}[/i]

Please help. Thank you.

Sponsor our Newsletter | Privacy Policy | Terms of Service