HHawk Posted July 31, 2008 Share Posted July 31, 2008 I am having some problems with photo script. When a user uploads a picture, it has to be moderated by an admin. The admin can choose to deny or allow the pictured to be visible for other users. When the admin chooses to allow the picture to be visible, the user receives an email where it says that his or her picture was approved and is visible online. This part of the script works! When the admin chooses to deny the picture to be visible, the user also receives an email, where it says that his or her picture was denied and a few possible reasons. And this part of the script does or will not work! The problem is, the picture is getting denied, it even says so in the user account (denied), however the person does not receive an email! I tried to correct it myself, but alas no go... And I don't know much about PHP, most of the time I can fix things by looking at another part, but not this time. So please help me out! 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]}'"); $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); } 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("update error: ".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()); //echo $sql_select; $sql_links2 = mysql_query($sql_select2) or DIE(mysql_error()); $num_links = mysql_num_rows($sql_links); // sets offset to we can se how many rows are returned 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) { // has remainder so add one 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]"; // gets the time it was added $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> - \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> - \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"); ?> Can someone take a look at it, maybe I missed something? Thanks in advance. Regards, HHawk Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/ Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 do you have the user id and action type in $_POST["approve_"] such as (5, deny)? does the delete work? Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-604868 Share on other sites More sharing options...
HHawk Posted July 31, 2008 Author Share Posted July 31, 2008 Sorry I do not fully understand you. I really lack PHP skills. :S Anyways, the delete works; image gets deleted. Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-604872 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 can you echo _POST["aprove_"]? i want to see what is getting posted Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-604880 Share on other sites More sharing options...
ainoy31 Posted July 31, 2008 Share Posted July 31, 2008 can you echo $_POST["aprove_"]? i want to see what is getting posted Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-604972 Share on other sites More sharing options...
HHawk Posted August 1, 2008 Author Share Posted August 1, 2008 can you echo $_POST["aprove_"]? i want to see what is getting posted It doesn't show anything? Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-605346 Share on other sites More sharing options...
HHawk Posted August 1, 2008 Author Share Posted August 1, 2008 I tried edited it, but all it gave me was a blank page... // send deny email here // SendUserEmail($goemail['email'],$DeclinePhotoEmailSubject,$reason_email); echo "<p>The email address is: "$goemail['email']"<br> The Subject is: "$DeclinePhotoEmailSubject"<br> The message is: "$reason_email; Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-605471 Share on other sites More sharing options...
HHawk Posted August 4, 2008 Author Share Posted August 4, 2008 Unfortunately I still am having the problem. Once more: When I approve a picture / photo, the user get's an email (or notification) where it says their picture / photo has been approved. When I deny a picture / photo, the user does not get an email (or notification) that their picture / photo has been denied. Can someone please look at the code, maybe their is something wrong with it... Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-607468 Share on other sites More sharing options...
HHawk Posted August 5, 2008 Author Share Posted August 5, 2008 * bump * Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-608428 Share on other sites More sharing options...
HHawk Posted August 6, 2008 Author Share Posted August 6, 2008 * bump * Link to comment https://forums.phpfreaks.com/topic/117583-problem-with-script-does-not-send-denied-email/#findComment-609512 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.