Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Dec 2005
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Thumbs down Script refuses to send email... Well partially...

    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 Code:
    <?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 or $Deleted >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:
    PHP Code:
    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!

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    What happens if you comment-out this line and echo some things?

    PHP Code:
    // SendUserEmail($goemail['email'],$DeclinePhotoEmailSubject,$reason_email);
    echo "email address: $goemail['email'] <br> \n";
    echo 
    "subject: $DeclinePhotoEmailSubject <br> \n";
    exit; 
    I'm thinking there is a failure in that line and your script is halting.

    I also question this variable: $DeclinePhotoEmailSubject
    Logic would tell me that you would have named it: $DeniedPhotoEmailSubject
    Did you name it the same in all locations?

  • #3
    New Coder
    Join Date
    Dec 2005
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks for taking the time help me...

    $DeclinePhotoEmailSubject is named the same throughout the scripts.

    I used your code, however it gave me an error:

    PHP Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING
    Anyways I edited it in:
    PHP Code:
    echo $goemail['email'];
    echo 
    $DeclinePhotoEmailSubject;
    exit; 
    This results in only showing the $DeniedPhotoEmailSubject, but it does not output the $goemail['email'] for some reason.

    And yes there is a working email address in the database, cause I do receive an email when I approve a picture.

  • #4
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    hhmph!

    That is so bizarre!

    ... and I no longer have much hair either ... I never attributed that to programming

    How about this idea ...
    You go into your MySQL (by hand) and edit the one thing that
    makes an accepted entry ... a denied entry. See if there's a way
    to figure out which "field" or table entry is making a difference.

  • #5
    New Coder
    Join Date
    Dec 2005
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    ... and I no longer have much hair either ... I never attributed that to programming
    LOL

    How about this idea ...
    You go into your MySQL (by hand) and edit the one thing that
    makes an accepted entry ... a denied entry. See if there's a way
    to figure out which "field" or table entry is making a difference.
    Uhm I checked the MySQL DB twice, but I cannot seem to find it?
    Where should it be located?

  • #6
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,471
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    Accessing the MySQL varies from webhost to webhost.
    My webhost has a control panel CPANEL where I go in and
    view/edit the MySQL database (it uses PHPMyAdmin).

    I don't know what you're using, but you just sort of have to
    browse around and look for the tables that contain the right
    fields and edit the values.

    I'm just grabbing at straws, thinking of some way to figure-out
    what's different between the two.

  • #7
    New Coder
    Join Date
    Dec 2005
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Well I looked several times in the MySQL database, but I couldn't find anything related. The only thing I could find, was the status of a picture (on how it shows in the user's profile e.g. checking / approved / denied), but nothing related to the approved / denied emails. :S

  • #8
    New Coder
    Join Date
    Dec 2005
    Posts
    19
    Thanks
    2
    Thanked 0 Times in 0 Posts
    w00t w00t...

    I think I solved it...

    I changed this:

    PHP Code:
     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]}'");
                    
    $goemail mysql_fetch_array($getemail);

                    if (
    $index == "delete"){
                       
    //echo "key= ". $key ."index = ". $index;
                       
    mysql_query("delete from $pic_tbl where picid = '{$key}'");
                       
    $Deleted++;
                       if (
    $Deleted >1){
                          
    $DeletedResults "($Deleted) Photos Have Been Deleted<br />";
                      } else {
                          
    $DeletedResults "($Deleted) Photo Has Been Deleted<br />";
                      }
                    } elseif (
    $index == "deny"){// start deny email
                       
    $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}'");

                       
    // send deny email here
                       
    SendUserEmail($goemail['email'],$DeclinePhotoEmailSubject,$reason_email); 


    Into this:

    PHP Code:
      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 * from $usr_tbl where id = '{$_POST["user_"][$key]}'");
                    
    $goemail mysql_fetch_array($getemail);

                    if (
    $index == "delete"){
                       
    //echo "key= ". $key ."index = ". $index;
                       
    mysql_query("delete from $pic_tbl where picid = '{$key}'");
                       
    $Deleted++;
                       
    $DeletedResults "($Deleted) Photo's Have Been Deleted<br />";
                    } elseif (
    $index == "deny"){// start deny email
                        // while (list($key,$index) = each ($_POST["del_"])){
                       
    $Denied++;
                       
    $DenyResults "($Denied) Photo's Have Been Denied<br />";
                       
    //while (list($key2,$index2) = each ($index)){
                       
    $reason_email ereg_replace("(\r\n|\n|\r)""<br />"$_POST["reason"][$key]);
                       
    mysql_query("update $pic_tbl set status = '5' where picid = '{$key}'");

                       
    // send deny email here
                       
    SendUserEmail($goemail['email'],$DeclinePhotoEmailSubject,$reason_email); 
    At least I am getting a denied email!

    I have to test the other functions though, to check if they still work.

    Can someone please explain what was causing the problem? So I can understand what I did?

    Cause I just added and removed stuff...

    //Update

    Okay I tested it somewhat more... The approved emails work also.

    Though, I have one problem. I think it's caused by the fact I changed something, somewhere previously... In the admin control panel you have 3 options; Approve, Deny and Delete. Approve and Deny now work 100&#37;, but when I press Delete it does not delete the picture from the pictures directory (but it does delete the MySQL entry).

    Any ideas on how to fix this? Also if the users presses the delete button from their control panel, it does get deleted...


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •