personal-reminder

Gesponsorde koppelingen

PHP script bestanden

  1. personal-reminder

« Lees de omschrijving en reacties

DATABASE:

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;


<<database.inc.php>>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
<?php
$mysql_link
= mysql_connect("localhost", "name", "password");
mysql_select_db("database") or die("Could not select database");
?>


<<reminder_list.php>>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
<?php
include('database.inc.php'); // Our database connectivity file
if( empty($_GET['reminder_id']) )
{

?>

<html>
<head><title>List of Reminders</title></head>
<body>
<table width="90%" border="0" align="center">
<tr>
<td colspan='3'><a href='reminder_setup.php'>Add new Reminder</a></td>
</tr>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
<?php
$result
= mysql_query( "SELECT * FROM reminder_events" );
$nr = mysql_num_rows( $result );
if(empty($nr))
{

echo("
<tr>
<td colspan='3'>No Reminders setup</td>
</tr>
"
);
}

while( $row = mysql_fetch_array( $result ))
{

$reminder_name = $row["reminder_name"];
$reminder_date = $row["reminder_year"]."-".$row["reminder_month"]."-".$row["reminder_date"];
$reminder_id = $row["reminder_id"];
echo("
<tr>
<td width='60%'>$reminder_name</td>
<td width='30%'>$reminder_date</td>
<td width='10%'><a href='reminder_list.php?reminder_id=$reminder_id'>delete</a></td>
</tr>
"
);
}

mysql_free_result( $result );
?>

</table>
</body>
</html>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
<?php
}
else
{
mysql_query( "DELETE FROM reminder_events WHERE reminder_id='".addslashes($_GET['reminder_id'])."'" );
// Let's go back to the Reminder List page
Header("Refresh: 1;url=reminder_list.php");
echo <<< _HTML_END_
Reminder Deleted, redirecting...
_HTML_END_;
}

?>


<<reminder_send.php>>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
include('database.inc.php'); // Our database connectivity file
// Values you need set

$number_of_days_before = 1;
$email = "[email protected]";
$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" );
}

?>


<<reminder_setup.php>>

Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
<?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">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
<?php
$current_year
= date("Y");
for($counter=$current_year;$counter<=$current_year+2;$counter++)
{

echo("\n<option>$counter</option>");
}

?>

</select>
<select name="reminder_month">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
<?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">
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
<?php
for($counter=1;$counter<=31;$counter++)
{

if($counter < 10)
$prefix = "0";
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>
</body>
</html>
Code (php)
PHP script in nieuw venster Selecteer het PHP script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<?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 );
}
}

?>


EINDE SCRIPT

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.