samedi 25 avril 2015

mysql database send alert email by date and time


I am trying to create a auto email that will send an email once the date and time have been met in the mysql database. The following fields are needed name, email address, date and time of notification to be sent, account number, notes. I have created my HTML Form, PHP to enter the data and the mysql database. I have searched all over to find where to find code for the looping search of date and time.

HTML Code

<title>Reminder Email</title>

<style type="text/css">
.style166 {color: #FFFFFF}
</style>

</head>

<body>

<form name="reminder_email" action="reminder.php" method="post">
<table id="reminder_email">
<tbody>
<tr>
    <td bgcolor="#0000FF"><div align="center" class="style166">Reminder Email</div></td>
    </tr>
    <tr><td width="235" rowspan="5" valign="top" style="border:1px solid black; border-color:black;">
    <div align="left">Name</div>
    <div align="left">
    <input type="text" name="name" size="30">
    </div>
<br/>
    <div align="left">Email Address</div>
    <div align="left">
    <input type="text" name="name" size="30">
    </div>
<br/>
    <div align="left">Alert Date</div>
    <div align="left">
    <input type="date" name="date" size="30">
    <div align="left">Format MM/DD/YYYY</div>
</div>
<br/>
    <div align="left">Alert Time</div>
    <div align="left">
    <input type="time" name="time" size="30">
    <div align="left">Please use military time.</div>
</div>
<br/>
<div>
    <div align="left">ESL Ticket Number</div>
    <div align="left">
    <input type="text" name="eslticket" size="30">
</div>
<br/>
    <div align="left">Notes:</div>
    <div align="left">
    <textarea cols="25" rows="5" name="notes"></textarea>
</div>
<br/>
<div>
</form>  
    <div align="center">
    <input type="submit" value="Submit">
    <input type="reset" value="Clear">
    </div></td>
</div></tbody>
</body></html>

PHP Code

<?php

define('DB_NAME', 'reminder');
define('DB_USER', 'reminder');
define('DB_PASSWORD', '');
define('DB_HOST', 'localhost');

$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);

if (!link) {
    die('Could not connect: ' . mysql_error());
}

$db_selected = mysql_select_db(DB_NAME, $link);

if (!db_selected) {
    die('Can\'t use ' . DB_NAME . ' : ' . msql_error());
}

$name = $_POST['name'];
$email = $_POST['email'];
$date = $_POST['date'];
$time = $_POST['time'];
$eslticket = $_POST['eslticket'];
$notes = $_POST['notes'];





$sql = "INSERT INTO alert (name, email, date, time, eslticket, notes) VALUES ('$name', '$email', '$date', '$time', '$eslticket', '$notes')";

if (!mysql_query($sql)) {
    die('Error: ' . mysql_error());
}

mysql_close();

echo "<script type='text/javascript'>alert('Alert Entered.');</script>";

?>

<meta http-equiv="refresh" content="0;url=http://ift.tt/1KgnfvH">


Aucun commentaire:

Enregistrer un commentaire