Hi
Very new to PHP
Just got a GuestBook working with a Flash MX interface, the code im using for guestbook.php is below.
What I need help with, is having an automated email sent to an address when a user leaves a message (to let me know some1 has signed the book). The email needs to contain the message the user left, their email, name etc.
Can any1 give me an example of the code needed? Is it hard to do?
Thanks for any help!
*******GuestBook.php********
<?php
$Submit = $POST["Submit"];
$Name = $POST["Name"];
$Email = $POST["Email"];
$Website = $POST["Website"];
$Comments = $POST["Comments"];
$NumLow = $REQUEST["NumLow"];
$NumHigh = $_REQUEST["NumHigh"];
$Name = ereg_replace("[A-Za-z0-9 ]", "", $Name);
$Email = ereg_replace("[A-Za-z0-9 @.-\/\']", "", $Email);
$Comments = ereg_replace("[A-Za-z0-9 @.-\/\']", "", $Comments);
$Website = eregi_replace("http://", "", $Website);
$Website = ereg_replace("[A-Za-z0-9 @.-\/\'\~:]", "", $Website);
$Name = stripslashes($Name);
$Email = stripslashes($Email);
$Website = stripslashes($Website);
$Comments = stripslashes($Comments);
if ($Submit == "Yes") {
$filename = "GuestBook.txt";
$fp = fopen( $filename,"r");
$OldData = fread($fp, 80000);
fclose( $fp );
$Today = (date ("l dS of F Y ( h:i:s A )",time()));
$Input = "Name: <b>$Name</b><br>Email: <b><u><a href=\"mailto:$Email\">$Email</a></u></b><br>Website: <b><u><a href=\"http://$Website\" target=\"_blank\">$Website</a></u></b><br>Comments: <b>$Comments</b><br><i><font size=\"-1\">Date: $Today</font><br><br>.:::.";
$New = "$Input$OldData";
$fp = fopen( $filename,"w");
if(!$fp) die("&GuestBook=cannot write $filename ......&");
fwrite($fp, $New, 800000);
fclose( $fp );
}
$filename = "GuestBook.txt";
$fp = fopen( $filename,"r");
$Data = fread($fp, 800000);
fclose( $fp );
$DataArray = split (".:::.", $Data);
$NumEntries = count($DataArray) - 1;
print "&TotalEntries=$NumEntries&NumLow=$NumLow&NumHigh=$NumHigh&GuestBook=";
for ($n = $NumLow; $n < $NumHigh; $n++) {
print $DataArray[$n];
if (!$DataArray[$n]) {
Print "<br><br><b>No More entries</b>";
exit;
}
}
?>