Page 1 of 1
PHP newbie!
Posted: Mon May 05, 2003 4:24 am
by flibbs
Very new to PHP
I want to be able to send an automated email to an address when a user signs a gestbook - to let me know some1s signed it. I've got the guestbook working, no idea about the automated email bit
Thanks for any help
Posted: Mon May 05, 2003 4:28 am
by []InTeR[]
You can add a
mail() function in the part where you add the users comment to the guestbook.
Posted: Mon May 05, 2003 5:07 am
by flibbs
wonder if u could give me an example? I've got GuestBook.php , heres the code im using. It connects to a flash mx interface.
<?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;
}
}
?>