<?php
/*
-----
Application: Flash-dB GuestBook Version 2.0
Details: mySQL and PHP powered GuestBook
Author: Mohsin Sumar
Website:
http://www.flash-db.comSupport:
http://www.flash-db.com/BoardNotes: Coments are marked by using comment entries symbols. Eg: // Comment
-----
*/
// Part One - Initiate a mySQL Database Connection
// Database Connectivity Variables and other Variables
$DBhost = "localhost"; // Database Server
$DBuser = "hindsgavlfestiv"; // Database User
$DBpass = "gvGeUhn2"; // Database Pass
$DBName = "hindsgavlfestiv"; // Database Name
$table = "ophold"; // Database Table
$numComments = 10; // Number of Comments per page
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass) or die("Fejl: " . mysql_error());
// Select mySQL Database
mysql_select_db($DBName, $DBConn) or die("Fejl: " . mysql_error());
// Part Two - Choose what action to perform
$action = $_GET['action'];
switch($action) {
case 'read' :
// Fetch all comments from database table
$sql = 'SELECT * FROM `' . $table . '`';
$allComments = mysql_query($sql, $DBConn) or die("Fejl: " . mysql_error());
$numallComments = mysql_num_rows($allComments);
// Fetch page-wise comments from database table
$sql .= ' ORDER BY `time` DESC LIMIT ' . $_GET['NumLow'] . ', ' . $numComments;
$fewComments = mysql_query($sql, $DBConn) or die("Fejl: " . mysql_error());
$numfewComments = mysql_num_rows($fewComments);
// Generate Output for Flash to Read
print '&totalEntries=' . $numallComments . '&';
print "<br>&entries=";
if($numallComments == 0) {
print "No entries in the guestbook, as yet..";
} else {
while ($array = mysql_fetch_array($fewComments)) {
$navn = mysql_result($fewComments, $i, 'navn');
$email = mysql_result($fewComments, $i, 'email');
$kommentar = mysql_result($fewComments, $i, 'kommentar');
$time = mysql_result($fewComments, $i, 'time');
print '<b>Name: </b>' . $navn . '<br><b>Email: </b>' . $email . '<br><b>Comments: </b>' . $kommentar . '<br><i>Date: ' . $time . '</i><br><br>';
$i++;
}
}
// Print this only when there aren't any more entries..
if($_GET['NumLow'] > $numallComments) {
print 'No More Entries!&';
}
break;
case 'write' :
// Recieve Variables From Flash
$navn = ereg_replace("&", "%26", $_POST['navn']);
$email = ereg_replace("&", "%26", $_POST['email']);
$adresse = ereg_replace("&", "%26", $_POST['adresse']);
$enkelt = ereg_replace("&", "%26", $_POST['enkelt']);
$dobbelt = ereg_replace("&", "%26", $_POST['dobbelt']);
$ankomst = ereg_replace("&", "%26", $_POST['ankomst']);
$afrejse = ereg_replace("&", "%26", $_POST['afrejse']);
$boern = ereg_replace("&", "%26", $_POST['boern']);
$festivalbord = ereg_replace("&", "%26", $_POST['festivalbord']);
$kommentar = ereg_replace("&", "%26", $_POST['kommentar']);
$submit = $_POST['submit'];
// Current system date in yyyy-mm-dd format
$submitted_on = date ("Y-m-d H:i:s",time());
// Check if its submitted from Flash
if($submit == 'Yes'){
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
' (`ID`,
`navn`,
`email`,
`adresse`,
`enkelt`,
`dobbelt`,
`ankomst`,
`afrejse`,
`boern`,
`festivalbord`,
`kommentar`,
`time`
)
VALUES
(\'\','
. '\'' . $navn . '\','
. '\'' . $email . '\','
. '\'' . $adresse . '\','
. '\'' . $enkelt . '\','
. '\'' . $dobbelt . '\','
. '\'' . $ankomst . '\','
. '\'' . $afrejse . '\','
. '\'' . $boern . '\','
. '\'' . $festivalbord . '\','
. '\'' . $kommentar . '\','
. '\'' . $submitted_on . '\'
)';
$insert = mysql_query($sql, $DBConn) or die("Fejl: " . mysql_error());
// If you want your script to send email to both you and the guest, uncomment the following lines of code
// Email Script Begin
$MyName = "Bekræftelse af bestilling fra hindsgavlfestival.dk";
$MyEmail = "jesper@stevnhoved.eu";
$Subject = "$name har bestilt ophold på hindsgavlfestival.dk.";
$Subject2 = "Kære $name - Vi har modtaget din bestilling på hindsgavlfestival.dk.";
$EmailBody = "$navn\n$email\n$adresse\n$enkelt\n$dobbelt\n$ankomst\n$afrejse\n$boern\n$festivalbord\n$kommentar";
$EmailBody2 = "$navn\n$email\n$adresse\n$enkelt\n$dobbelt\n$ankomst\n$afrejse\n$boern\n$festivalbord\n$kommentar";
$EmailFooter = "";
$EmailFooter2 = "Du modtager snarest en mail fra os med endelig bekræftelse og info om betaling.";
$Message = $EmailBody.$EmailFooter;
$Message2 = $EmailBody2.$EmailFooter2;
mail($MyName." <".$MyEmail.">",$Subject, $Message, "From: ".$name." <".$email.">");
mail($name." <".$email.">", $Subject, $Message2, "From: ".$MyName." <".$MyEmail.">");
// Email Script End
print "&gb_status=Tak for bestillingen. Vi har sendt en mail til dig. Bekræftelse og info vedr. betaling følger indenfor 48 timer. &done=yes&";
return;
}
print "&_root.write.gb_status=Bestilling blev IKKE sendt!&";
break;
}
?>