Okay here is the deal; I am busy with a website, a photo website to be more precise. Every picture which is uploaded will be moderated for obvious reasons.

The good:
When I approve a picture in my control panel, it works like it should. The uploader gets an email which states his picture was approved by the administrator and picture is displayed on the website. And it says "Approved" in the user's controlpanel. So this is great...

The bad:
Whenever I deny a picture for whatever reason (e.g. adult content), the picture gets processed as denied and it shows in the user's controlpanel as being denied. So far, so good. However, the user does not get the denied picture email.

In short:
Picture gets approved = user gets an email that his or her picture was approved for displaying on the website.

Picture gets denied = user does not get an email that his or her picture was denied for displaying on the website. Though it does get processed by the script. The only fault here is the fact the user does not get the email.

Here is the script:

<?php
session_start();

require("../config.php");
require("adminglobal.php");
$AdminInfo =& new Admin();
if (!$AdminInfo->VerifyAdminSession()){
     header("location: index.php");
}
include("../templates/admin/adminheader.html.php");
echo  "</head>
 <body onload=\"FullScreen_go();\">
 <div>";
 if (isset($_POST["action"]) AND isset($_POST["action"]) == "save"){
            $Deleted = 0;
            $Denied = 0;
            $Approved = 0;
            while (list($key, $index) = each ($_POST["approve_"])){
                $getemail = mysql_query("select id,userid,email from $usr_tbl where id = '{$_POST["user_"][$index]}'") or die (mysql_error());
                $goemail = mysql_fetch_array($getemail);

            if ($index == "delete"){
               mysql_query("delete from $pic_tbl where picid = '{$key}'") or die (mysql_error());
               $Deleted++;
               if ($Deleted >1){
                  $DeletedResults = "($Deleted) Photos Have Been Deleted<br />";
              } else {
                  $DeletedResults = "($Deleted) Photo Has Been Deleted<br />";
              }
            } elseif ($index == "deny"){
               $Denied++;
               if ($Denied >1){
                   $DenyResults = "($Denied) Photos Have Been Denied<br />";
              } else {

                   $DenyResults = "($Denied) Photo Has Been Denied<br />";
              }
               $reason_email = ereg_replace("(\r\n|\n|\r)", "<br />", $_POST["reason"][$key]);

			   mysql_query("update $pic_tbl set status = '5' where picid = '{$key}'") or die (mysql_error());

			   SendUserEmail($goemail['email'],$DeclinePhotoEmailSubject,$reason_email);

            } else {
                $Approved++;
                if ($Approved > 1){
                      $ApproveResults = "($Approved) Photos Have Been Approved<br />";
                } else {
                    $ApproveResults = "($Approved) Photo Has Been Approved<br />";
                }
                $SignupEmail = str_replace("{PIC}", $_POST['pic'][$key],$GrantedPhotoEmail);
                $SignupEmail = str_replace("{PICID}", $key,$SignupEmail);
                $SignupEmail = str_replace("{NAME}", $goemail['userid'],$SignupEmail);
                SendUserEmail($goemail['email'],$GrantedPhotoEmailSubject,$SignupEmail);

                $sitedate = $_POST['siteyear'][$key]."-".$_POST['sitemonth'][$key]."-".$_POST['siteday'][$key]." ".date('G').":".date('i').":".date('s');
                $sitedate = strtotime($sitedate);

                mysql_query("update $pic_tbl set picture='{$_POST['pic'][$key]}', dateadded = '$sitedate',ncat='{$_POST['category_wanted'][$key]}', status='1',admincomment = '{$_POST["comment_"][$key]}' where picid = '{$key}'") or die (mysql_error());
            }
      }
      if ($Approved > 1 or $Deleted >1 or $Denied >1){
          $exs = "s";
      }
      $header = "Approved Photo$exs";
      include("../templates/admin/header.html.php");
      echo "<div class=\"error\">$DeletedResults $DenyResults $ApproveResults</div>";
      exit;
}


$header = "All Pending Photos";
include("../templates/admin/header.html.php");


$sql_select = "select * from $pic_tbl,$usr_tbl where pic_userid=id AND $pic_tbl.status='2' order by picid ASC $limitq";
$sql_select2 = "select picid from $pic_tbl,$usr_tbl where pic_userid=id AND $pic_tbl.status='2'";
$sql_links = mysql_query ($sql_select) or DIE(mysql_error());

$sql_links2 = mysql_query($sql_select2) or DIE(mysql_error());

$num_links =  mysql_num_rows($sql_links);

	    if (empty($_GET["ofs"])){
	        $all_links = mysql_num_rows($sql_links2);
	        $_SESSION['all_links'] = $all_links;

	    }
		$firstrowonpage = $_GET["ofs"] + 1;

$nav = admin_page_num("photopending.php",$_GET['action'], $all_links, $admin_member_per_page, $pagenum, $_GET['ofs'],$sitecatid,$mainorder,'',$sortby);
$totalpages = intval($all_links / $admin_member_per_page);
if ($all_links%$admin_member_per_page) {
    $totalpages++;
}


if ($num_links){
    $pitems = '';
    echo "    <form action=\"photopending.php\" method=\"post\">\n";
    for ($i=0; $i<$num_links; $i++){
        $row = mysql_fetch_array($sql_links);

    $size = GetNewImageSize($row['picture']);
    $picture = $siteurl."/thumbnailer.php?p=".$row['picture']."&w=$size[0]&h=$size[1]";

    $date = date('Y-m-d', $row['dateadded']);
    $joindate = explode("-", $date);
    $sitedate = "<select name=\"siteyear[{$row['picid']}]\">\n";
    $sitedate .= "                     <option value=\"\">-------</option>\n";
    for($x=2002; $x<2015; $x++){
        $selected = ($joindate[0] == $x)?"selected=\"selected\"":"";
        $sitedate .= "                  <option value=\"$x\" $selected>$x</option>\n";
    }
    $sitedate .= "                   </select>&nbsp;-&nbsp;\n";
    $sitedate .= "                   <select name=\"sitemonth[{$row['picid']}]\">\n";
    $sitedate .= "                       <option value=\"\">-------</option>\n";
    for ($y=01; $y<13; $y++){
        $selected = ($joindate[1] == $y)?"selected=\"selected\"":"";
        $sitedate .= "                    <option value=\"$y\" $selected>$y</option>\n";
    }
    $sitedate .= "                     </select>&nbsp;-&nbsp;\n";
    $sitedate .= "                     <select name=\"siteday[{$row['picid']}]\">\n";
    $sitedate .= "                         <option value=\"\">-------</option>\n";
    for ($z=01; $z<32; $z++){
        $selected = ($joindate[2] == $z)?"selected=\"selected\"":"";
        $sitedate .= "                     <option value=\"$z\" $selected>$z</option>\n";
    }
     $sitedate .= "                    </select>";

    $color = ($color == "#ededed")?"#D9D9D9":"#ededed";
    $DeclineEmail = str_replace("<br />","\r\n", $DeclinePhotoEmail);
    $DeclineEmail = str_replace("{NAME}",$row['userid'], $DeclineEmail);
    include("list_admin3.php");
    eval("\$pitems .= \"".gettemplate("templates/admin/pending_item")."\";");

}
echo $pitems;
echo "    <table width=\"100%\"><tr>\n";
echo "        <td align=\"center\" >";
echo "        <input type=\"hidden\" name=\"action\" value=\"save\">\n";
echo "        <input type=\"submit\" name=\"send\" value=\"Approve Checked\">\n";
echo "        <input type=\"reset\" name=\"reset\" value=\"Reset Form\">\n";
echo "        </td>";
echo "    </tr></table></form>";
} else {
    echo"<div class=\"error\">$NoItemsToDisplay</div>";
}
include("../templates/admin/pagenumber.html.php");
echo"</table>\n";

include("../templates/admin/adminfooter.html.php");
?>

Things I have tried:

Echoing or printing the output of $geomail['email'] after SendUserEmail in the Denied PHP coding part. Result: Tt didn't show anything!? The other variables, if echoed, showed up just fine.

Changing $goemail['email'] in:

SendUserEmail($goemail['email'],$DeclinePhotoEmailSubject,$reason_email);

into an emailaddress of my own (fictional user). Result: the fictional user (me in this case) did receive the email.

I really don't understand why it does not send out the "picture has been denied"-email (when I deny a picture), while it does send out the "picture has been approved"-email (when I approve a picture). Since the code is almost the same...

Any advice, suggestions or even a solution? Cause after a week trial-and-error; I am really getting bald.

Thanks for reading in advance!

    edit: Sorry, misinterpreted code.

    Ehm.. Did you echo out all the variables in the senduseremail? Does that generate the internal vars that you expect?

    I suppose that is the function we should look at, unless the mysql_query() just before sending of the email is wrong: you just let it die, withpout generating a message. Try adjusting that do: or die(mysql_error()) to see whether the script perhaps just stops at that point.

      HHawk;10880480 wrote:

      Things I have tried:

      Echoing or printing the output of $geomail['email'] after SendUserEmail in the Denied PHP coding part. Result: Tt didn't show anything!? The other variables, if echoed, showed up just fine.

      I already tried that.

        Write a Reply...