PHP newbie!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
flibbs
Forum Newbie
Posts: 2
Joined: Mon May 05, 2003 4:24 am

PHP newbie!

Post 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 :D

Thanks for any help
[]InTeR[]
Forum Regular
Posts: 416
Joined: Thu Apr 24, 2003 6:51 am
Location: The Netherlands

Post by []InTeR[] »

You can add a mail() function in the part where you add the users comment to the guestbook.
flibbs
Forum Newbie
Posts: 2
Joined: Mon May 05, 2003 4:24 am

Post 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;
}
}
?>
Post Reply