How to add a notification in a calendar

I've got a booking script. I'd like to get a notification in the bookers calendar, being it MS Outlook calendar, Google Calendar or any other popular caledar. I have very little experience in this field and seek basic "how to" information".
Serverside language: php.
Lennart EricsonAmateurAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
There is a calendar standard called hCalendar that implements RFC2445.  Some other keywords of interest are iCal and vCal.  These use the iCalendar file format which is the defacto standard for calendar information interchange.  

You may be able to use PHP to force a download of a file with the ics file suffix.  The client's computer may associate the .ics files with a calendar program.  This file extension is used for calendaring and scheduling information.

The MIME type for iCalendar data is text/calendar.

I've done this in the past with an "add this event to my calendar" link.  The link went to a PHP script and it had a URL parameter giving a key to the calendar entry.  The PHP script used the key to locate the event row in the calendar database table.  It generated an iCalendar object, which is a simple text file like this (thanks, Wikipedia)
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//hacksw/handcal//NONSGML v1.0//EN
BEGIN:VEVENT
UID:uid1@example.com
DTSTAMP:19970714T170000Z
ORGANIZER;CN=John Doe:MAILTO:john.doe@example.com
DTSTART:19970714T170000Z
DTEND:19970715T035959Z
SUMMARY:Bastille Day Party
END:VEVENT
END:VCALENDAR

Open in new window

If I can find a code example for this, I'll post it here and update these articles about handling date and time in PHP.
http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL-Procedural-Version.html
http://www.experts-exchange.com/articles/20920/Handling-Time-and-Date-in-PHP-and-MySQL-OOP-Version.html
Ray PaseurCommented:
Here's the only example I can find, and it probably dates from about 15 years ago!  The code should be refactored (obviously) but the iCalendar object works correctly.  You can probably guess the calendar table structure from the variable names.  The "poc" means "point of contact."
<?php 
require_once('common.php');
error_reporting(E_ALL ^ E_NOTICE);

$_key = $_GET["k"];
if (!integer_string($_key)) die("Bad Key");

$filename = "LBBEvent" . $_key . ".vcs";
header("Content-Type: text/x-vCalendar");
header("Content-Disposition: inline; filename=$filename");

$sql = "SELECT * FROM calendar "WHERE _key = $_key LIMIT 1";
if (!$res = mysql_query($sql)) { query_error($sql); }
$num_rows = mysql_num_rows($res);

if ($num_rows == 0) {
    echo "Sorry, the <b>Event Key $_key</b> is not found in the calendar.<br /><br />\n";
    echo "Please report this error to the curator.<br /><br />\n";
    die("Sorry, Unable to add to your calendar.");
}
if ($num_rows != 1) {
    echo "SQL $sql<br>";
    echo "RESULT $result<br><br>";
    echo "The <b>Event Key $_key</b> appears to have $num_rows data base entries in the calendar (yikes!)<br />\n";
    echo "Please report this error to the curator.<br /><br />\n";
    die("Sorry, Unable to add to your calendar.");
}

$calendar_array = mysql_fetch_assoc($res);
extract($calendar_array);

$loc = trim($location);
if ($loc  != '') { $loc  = '=0D=0A=Location: ' . $loc; }

$poc1 = trim($poc1_name .' '. $poc1_phone .' '. $poc1_email);
if ($poc1 != '') { $poc1 = '=0D=0A=Contact: ' . $poc1; }

$poc2 = trim($poc2_name .' '. $poc2_phone .' '. $poc2_email);
if ($poc2 != '') { $poc2 = '=0D=0A=Contact: ' . $poc2; }

$pocw = trim($poc_url);
if ($pocw != '') { $pocw = '=0D=0A=WWW: ' . $pocw; }

$poc = $poc1 . $poc2 . $pocw;

// CALENDAR TOLERATES END TIMESTAMPS WRONG OR OMITTED - VCAL DOES NOT
$vcal_dtstart = date('Y-m-d H:i:sO', strtotime($start));
$vcal_dtend   = date('Y-m-d H:i:sO', strtotime($end));
if ($vcal_dtend < $vcal_dtstart) { $vcal_dtend = $vcal_dtstart; }


?>BEGIN:VCALENDAR
VERSION:1.0
PRODID:LBB Online Calendar
BEGIN:VEVENT
SUMMARY:<?php echo "$title" . "\n"; ?>
DESCRIPTION;ENCODING=QUOTED-PRINTABLE:<?php echo "$details" . "$loc" . "$poc" . "\n"; ?>
DTSTART:<?php echo $vcal_dtstart . "\n"; ?>
DTEND:<?php echo $vcal_dtend . "\n"; ?>
END:VEVENT
END:VCALENDAR

Open in new window

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Lennart EricsonAmateurAuthor Commented:
Thank you! Sorry for not having responded eaarlier.
Regards
Lennart
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Google Apps

From novice to tech pro — start learning today.