Could anyone take a quick look at this .php doc and let me know why I am not getting the email notification when an entry is posted? I’m tearing my hair out trying to figure it out!!!
Thanks!
<?
if (!isset($name) || !isset($email) || !isset($message) || empty($name) || empty($email) || empty($message)) {
print "&result=Fail";
print "&errorMsg=" . urlencode("Input required for all fields.");
exit;
}
$email = strtolower($email);
addentry($name, $email, $message);
function addentry($name, $email, $message) {
$posted = strftime("%D %I:%M %p");
$message = stripslashes($message);
$file = fopen('entry.txt', 'a+');
if (!$file) {
print "&result=Fail";
print "&errorMsg=" . urlencode("Could not open entry.txt file. Change CHMOD levels to 766.");
exit;
}
fputs($file, "<font color=\"#000000\">Name:</font> $name
<font color=\"#000000\">Email:</font> <font color=\"#CCCCCC\"><u><A href=\"mailto:$email\">$email</A></u></font><br>
<font color=\"#000000\">Posted:</font> $posted
<font color=\"#000000\">Message:</font> $message
");
fclose($file);
// Send admin an email when new entry occurs
// mailAdmin($name, $email);
}
function mailAdmin($name, $email) {
$mailTo = "Michael Mancilla <gb@hivandrelationships.com>";
$mailFrom = "From: Guestbook <gb@hivandrelationships.com>";
$mailSubject = "New Guestbook Entry";
$mailBody = "$name ($email) has just posted in your guestbook
View it at http://www.hivandrelationships.com";
mail($mailTo, $mailSubject, $mailBody, $mailFrom);
}
print "&result=okay";
exit;
?>
One last question about this code: as it is, if you don’t insert an email address, it requests one. What can I do to make that email input optional and not mandatory?
Thanks!!
oy … worked only half way: although it did not give me an error when I omitted the email, it no longer sends me an email. And now, even after having put back the original code, it still doesn’t work …
Here it is, if you want to see it: http://www.hivandrelationships.com/phpGuestBook/guestbook.html
Yes … and now that I think about it, what I originally did was simply copy/paste your code from this page onto my .php doc. Maybe I should simply type it all out by hand?
I’ll duplicate/save my original php this time and try again.
Whatever the case,thanks ever so much for taking the time to help me out; I truly appreciate it.