PDA

View Full Version : Comment Email Form


Birdie
06-08-2005, 03:46 PM
Hello;

When I upgraded PP I messed up my comments form. I used to have it so it would email me the url and email address of the commentor. Now I can get it to send me the email address, but not the url. Also, I'd like to remove the thumbnail in the email (because I can't view it anyhow) and just have the image url and title. Is this possible?

// EMAIL NOTE ON COMMENTS
// ################################################## ########################################//
if($cfgrow['commentemail'] == "yes") {
if($_GET['x'] == "save_comment") {
$admin_email = $cfgrow['email'];
$comment_name = clean($_POST['name']);
$comment_image_id = $_POST['parent_id'];
$comment_message = $_POST['message'];
$comment_message = stripslashes($comment_message);
$comment_url = clean($_POST['url']);
$comment_email = clean($_POST['usemail']);
$link_to_comment = $cfgrow['siteurl']."index.php?showimage=$comment_image_id";
$comment_image_name = $_POST['parent_name'];
$link_to_comment = $cfgrow['siteurl']."?showimage=$comment_image_id";
$link_to_img_thumb_cmmnt = "Thumbnail Link:" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name";
$img_thumb_cmmnt = "<img src='" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name' >";
$subject = "Uncommon Depth - New Comment Made";
$sent_date = gmdate("Y-m-d",time()+(3600 * $cfgrow['timezone'])) ;
$sent_time = gmdate("H:i",time()+(3600 * $cfgrow['timezone'])) ;
if ($cfgrow['htmlemailnote']!='yes')
{
// Plain text note email
$body = "Hello,\r\n
A new comment has been made at your photoblog.
$link_to_comment

The Comment is
----------------------------------------------------------------------
$comment_message
by $comment_name - $comment_email - $comment_url
----------------------------------------------------------------------
Email Sent by pixelpost
";
$headers = "Content-type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: Uncommon Depth <$comment_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
}
else
{
// HTML note email
$body = "Hello,<br>
A new comment has been made at your photoblog.<br><br>
<a href='$link_to_comment'>$link_to_comment</a><br>

<br>
The Comment is: <br>
----------------------------------------------------------------------<br>
$comment_message<br>
by $comment_name - $comment_email<br> <a href='$VINFO_URL'>$comment_url</a><br>
---------------------------------------------------------------------- <br>
Email Sent by Uncommon Depth<br>
";

////////////
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\n";

// Additional headers
$headers .= "From: <$comment_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
} // if (cfgrow['htmlemailnote']=='no')
} //if($_GET['x'] == "save_comment") {
} // commentemail yes

Is what I have in my index.php file. My site it http://www.uncommondepth.com/photos. Can anyone see what I'm missing?

Joe[y]
06-08-2005, 03:56 PM
try this:

// EMAIL NOTE ON COMMENTS
// ################################################## ########################################//
if($cfgrow['commentemail'] == "yes") {
if($_GET['x'] == "save_comment") {
$admin_email = $cfgrow['email'];
$comment_name = clean($_POST['name']);
$comment_image_id = $_POST['parent_id'];
$comment_message = $_POST['message'];
$comment_message = stripslashes($comment_message);
$comment_url = clean($_POST['url']);
$comment_email = clean($_POST['usemail']);
$link_to_comment = $cfgrow['siteurl']."index.php?showimage=$comment_image_id";
$comment_image_name = $_POST['parent_name'];
$link_to_comment = $cfgrow['siteurl']."?showimage=$comment_image_id";
$link_to_img_thumb_cmmnt = "Thumbnail Link:" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name";
$img_thumb_cmmnt = "<img src='" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name' >";
$subject = "Uncommon Depth - New Comment Made";
$sent_date = gmdate("Y-m-d",time()+(3600 * $cfgrow['timezone'])) ;
$sent_time = gmdate("H:i",time()+(3600 * $cfgrow['timezone'])) ;
if ($cfgrow['htmlemailnote']!='yes')
{
// Plain text note email
$body = "Hello,\r\n
A new comment has been made at your photoblog.
$link_to_comment

The Comment is
----------------------------------------------------------------------
$comment_message
by $comment_name - $comment_email - $comment_url
----------------------------------------------------------------------
Email Sent by pixelpost
";
$headers = "Content-type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: Uncommon Depth <$comment_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
}
else
{
// HTML note email
$body = "Hello,<br>
A new comment has been made at your photoblog.<br><br>
<a href='$link_to_comment'>$link_to_comment</a><br>

<br>
The Comment is: <br>
----------------------------------------------------------------------<br>
$comment_message<br>
by $comment_name - $comment_email<br> $comment_url<br>
---------------------------------------------------------------------- <br>
Email Sent by Uncommon Depth<br>
";

////////////
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\n";

// Additional headers
$headers .= "From: <$comment_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
} // if (cfgrow['htmlemailnote']=='no')
} //if($_GET['x'] == "save_comment") {
} // commentemail yes


as for the thumbnail. just change your settings in your options panel to just send text-based emails.

Birdie
06-08-2005, 04:33 PM
It didn't work. It still just sends the email address.

Now the funny thing is that despite changing the headers the email output remains the same, which is leading me to believe that changing the index.php file is having no effect whatsoever on the email output of the comments form. ???

I changed the "email sent by" to my domain name and the headers from field.

// Plain text note email
$body = "Hello,\r\n
A new comment has been made at your photoblog.
$link_to_comment

The Comment is
----------------------------------------------------------------------
$comment_message
by $comment_name - $comment_email - $comment_url
----------------------------------------------------------------------
Email Sent by Uncommon Depth
";
$headers = "Content-type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: Uncommon Depth <$comment_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
}

The text of my email reads:

"Hello,

A new comment has been made at your photoblog.
http://www.uncommondepth.com/photos/?showimage=153

The Comment is
----------------------------------------------------------------------
test
by Birdie - ****(nospam)@uncommondepth.com
----------------------------------------------------------------------
Email Sent by pixelpost"

(I removed the pertinent part of my email address here for security.)

It did not change the Email Sent by line, nor the headers. ???

Also, after you submit a comment you are redirected to a page that says something about "click to be taken back" and if you click it takes you back to the main page of the site but you are in a small pop-up window. Is there a way to redirect you back to the comments popup to view the comments?

Joe[y]
06-08-2005, 05:14 PM
try the code i use on my blog:

// ################################################## ########################################//
// EMAIL NOTE ON COMMENTS
// ################################################## ########################################//
if($cfgrow['commentemail'] == "yes") {
if($_GET['x'] == "save_comment") {
$admin_email = $cfgrow['email'];
$comment_name = clean($_POST['name']);
$comment_image_id = $_POST['parent_id'];
$comment_message = $_POST['message'];
$comment_message = stripslashes($comment_message);
$comment_email = clean($_POST['email']);
$link_to_comment = $cfgrow['siteurl']."index.php?showimage=$comment_image_id";
$comment_image_name = $_POST['parent_name'];
$link_to_comment = $cfgrow['siteurl']."?showimage=$comment_image_id";
$link_to_img_thumb_cmmnt = "Thumbnail Link:" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name";
$img_thumb_cmmnt = "<img src='" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name' >";
$subject = "New Comment Made at JLSpurling.com";
$sent_date = gmdate("Y-m-d",time()+(3600 * $cfgrow['timezone'])) ;
$sent_time = gmdate("H:i",time()+(3600 * $cfgrow['timezone'])) ;
if ($cfgrow['htmlemailnote']!='yes')
{
// Plain text note email
$body = "Hello,\r\n
A new comment has been made at your photoblog.
$link_to_comment

The Comment is
----------------------------------------------------------------------
$comment_message
by $comment_name - $comment_email
----------------------------------------------------------------------
Email Sent by pixelpost
";
$headers = "Content-type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: PIXELPOST <$admin_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
}
else
{
// HTML note email
$body = "Hello,<br>
A new comment has been made at your photoblog.<br><br>
<a href='$link_to_comment'>$link_to_comment</a><br><br>
$img_thumb_cmmnt<br>
<br>
The Comment is: <br>
----------------------------------------------------------------------<br>
$comment_message<br>
by $comment_name - $comment_email<br>
---------------------------------------------------------------------- <br>
Email Sent by pixelpost<br>
";

////////////
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\n";

// Additional headers
$headers .= "From: PIXELPOST <$admin_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
} // if (cfgrow['htmlemailnote']=='no')
} //if($_GET['x'] == "save_comment") {
} // commentemail yes

Birdie
06-08-2005, 06:39 PM
No change. So there must be something in my comment template that needs changing, but I can't figure out what.

<div id="addcomment">
<a name="addcomment"></a><b>Add your comment</b>
<form method="post" action="index.php?commment=save_comment_nospam" name="commentform" accept-charset="UTF-8">
<img width="120" height="30" src="includes/spamsecure.php" border="1" hspace="10" align="left">
please enter the correct code<br />because of security:
<input maxlength="5" size="5" name="userinput" type="text" value="">
<br clear="all">

<p><textarea name='message' rows='3' cols='10' style='width:50%' onFocus="clearBox(this);">Type Comment Here.</textarea></p>
<p><input type='text' name='name' class='input' value='' id="name"/>    <label for="name">Name</label></p>
<p><input type='text' name='url' class='input' value='' id="url"/>    <label for="url">Website URL, if any</label></p>
<p><input class='input' type='text' name='email' value='' id="email"/>    <label for="email">Email (not visible to others)</label></p>
<p><input type='checkbox' value='set' name='vcookie' id="saveinfo" /> <label for="saveinfo">Save User Info</label></p>
<input type='submit' value='Add' />
<input type='hidden' name='parent_id' value='<IMAGE_ID>' />
<input type='hidden' name='parent_name' value='<IMAGE_NAME>' />
</form>

Can anyone figure out what I'm doing wrong here?

Joe[y]
06-08-2005, 07:34 PM
nope. nothing wrong there. it was my fault i think... try this one :


// ################################################## ########################################//
// EMAIL NOTE ON COMMENTS
// ################################################## ########################################//
if($cfgrow['commentemail'] == "yes") {
if($_GET['x'] == "save_comment") {
$admin_email = $cfgrow['email'];
$comment_name = clean($_POST['name']);
$comment_image_id = $_POST['parent_id'];
$comment_message = $_POST['message'];
$comment_message = stripslashes($comment_message);
$comment_email = clean($_POST['email']);
$comment_url = $_POST['url'];
$link_to_comment = $cfgrow['siteurl']."index.php?showimage=$comment_image_id";
$comment_image_name = $_POST['parent_name'];
$link_to_comment = $cfgrow['siteurl']."?showimage=$comment_image_id";
$link_to_img_thumb_cmmnt = "Thumbnail Link:" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name";
$img_thumb_cmmnt = "<img src='" .$cfgrow['siteurl'] ."thumbnails/thumb_$comment_image_name' >";
$subject = "New Comment Made at JLSpurling.com";
$sent_date = gmdate("Y-m-d",time()+(3600 * $cfgrow['timezone'])) ;
$sent_time = gmdate("H:i",time()+(3600 * $cfgrow['timezone'])) ;
if ($cfgrow['htmlemailnote']!='yes')
{
// Plain text note email
$body = "Hello,\r\n
A new comment has been made at your photoblog.
$link_to_comment

The Comment is
----------------------------------------------------------------------
$comment_message
by <a href='$comment_url' >$comment_name</a> - $comment_email
----------------------------------------------------------------------
Email Sent by pixelpost
";
$headers = "Content-type: text/plain; charset=UTF-8\n";
$headers .= "Content-Transfer-Encoding: 8bit\n";
$headers .= "From: PIXELPOST <$admin_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
}
else
{
// HTML note email
$body = "Hello,<br>
A new comment has been made at your photoblog.<br><br>
<a href='$link_to_comment'>$link_to_comment</a><br><br>
$img_thumb_cmmnt<br>
<br>
The Comment is: <br>
----------------------------------------------------------------------<br>
$comment_message<br>
by <a href='$comment_url' >$comment_name</a> - $comment_email<br>
---------------------------------------------------------------------- <br>
Email Sent by pixelpost<br>
";

////////////
$headers = 'MIME-Version: 1.0' . "\n";
$headers .= 'Content-type: text/html; charset=UTF-8' . "\n";

// Additional headers
$headers .= "From: PIXELPOST <$admin_email>\n";
$recipient_email = "admin <$admin_email>";
mail($recipient_email,$subject,$body,$headers);
} // if (cfgrow['htmlemailnote']=='no')
} //if($_GET['x'] == "save_comment") {
} // commentemail yes

Birdie
06-08-2005, 10:20 PM
Okay, I was having a Duh! moment here. I had been doing it right all along, but I was doing 'it' in the wrong place. I've got the anti-comment-spam addon installed. I could change the code in index.php all I liked and it wasn't going to make a lick of difference to the output because the output was coming from anti-comment-spam.php. As soon as I realized that I got things working just fine.

Sorry to bother everyone. Thanks for your help. Now back to your regularly scheduled programming! :oops: