fireonwater Posted July 3, 2014 Share Posted July 3, 2014 hi i got a problem with my mailing list when i try to send photo within email , After sending the message to the subscriber mailing list message lose the title and text and image as well, this is the code mailing list, you can review and refer to mistakes that do, the mailing list by two types of options transmitter, the first to send a regular message text without the image and the second is to send a message contains a picture, the problem in sending out the message and image <?php session_start(); if(!isset($_SESSION['AssessuerSess'])){ header ("Location: index.php"); }else{ if(!(($_SESSION['AssessuerSess']=="done"))){ header ("Location: index.php?stat=na"); } } include 'files/info.php'; $userid = $_SESSION['auid']; if(isset($_POST['do'])){ $do = mysql_real_escape_string($_POST['do']); //id, useremail, registerredin if($do=="emailit"){ $thesubject = mysql_real_escape_string($_POST['subject']); $themessage = mysql_real_escape_string($_POST['message']); $themessage = wordwrap($themessage,69); $themessage = str_replace("\n.", "\n..", $themessage); $theheader = 'From: info@assesseur.com' . "\r\n"; $theheader.= "Content-Type: text; charset=UNICODE-1-1-UTF-8"; $thedatntime = $dater." ".$timer; $mailresult=mysql_query("SELECT useremail FROM tblmgroup UNION ALL SELECT usermail FROM tblusers WHERE nletter = 1"); $totallist = mysql_num_rows($mailresult); $mailedok = 0; $mailedno = 0; while($mailrs = mysql_fetch_array($mailresult)) { $theemail = $mailrs[0]; if(@mail($theemail,$thesubject,$themessage,$theheader)) { $mailedok++; }else{ $mailedno++; } } $thequery = "INSERT INTO tblmlist (subject, message, users, okusers, nousers, sentin, lastadmin) "; $thequery.= "VALUES ( ".$thesubject.", ".$themessage.", ".$totallist.", ".$mailedok.", ".$mailedno.", ".time().", ".$userid.")"; mysql_query("$thequery", $db); if(mysql_errno()==0) { $dbsave = 1; }else{ $dbsave = 0; } if($mailedok>0) { header ("Location: maillist.php?stat=mailok&ok=$mailedok&no=$mailedno&db=$dbsave"); break; }else{ header ("Location: maillist.php?stat=no&ok=$mailedok&no=$mailedno&db=$dbsave"); break; } }elseif($do=="addpic"){ $categoryimg = uniqid('card'); $ctitle = mysql_real_escape_string($_POST['title']); if(!empty($_FILES['image']['name'])) { if(($_FILES['image']['type']=="image/pjpeg")||($_FILES['image']['type']=="image/jpeg")){ $vtype = strrchr($_FILES['image']['name'],"."); $vtype = strtolower($vtype); $filename = $categoryimg.$vtype; $uploadthm = "../cards/".$filename; $src = $_FILES['image']['tmp_name']; $wmax = 550; $hmax = 300; $quality = 100; $source = imagecreatefromjpeg($src); $orig_w = imagesx($source); $orig_h = imagesy($source); if($orig_w>$wmax || $orig_h>$hmax) { $thumb_w = $wmax; $thumb_h = $hmax; if($thumb_w/$orig_w*$orig_h>$thumb_h) { $thumb_w = round($thumb_h*$orig_w/$orig_h); }else{ $thumb_h = round($thumb_w*$orig_h/$orig_w); } }else{ $thumb_w = $orig_w; $thumb_h = $orig_h; } $thumb = imagecreatetruecolor($thumb_w,$thumb_h); imagecopyresampled($thumb,$source,0,0,0,0,$thumb_w,$thumb_h,$orig_w,$orig_h); imagejpeg($thumb,"$uploadthm",$quality); imagedestroy($thumb); }else{ mysql_close($db); header ("Location: maillist.php?do=addpic&stat=onlyjpg"); break; } }else{ $filename = ""; } $classqu = "INSERT INTO tblmgcards (title, filename, timers, lastadmin) VALUES ('".$ctitle."', '".$filename."', ".time().", ".$userid.")"; mysql_query("$classqu", $db); if(mysql_errno()==0) { mysql_close($db); header ("Location: maillist.php?do=gallery&stat=added"); break; }else{ mysql_close($db); header ("Location: maillist.php?do=gallery&stat=no"); break; } }elseif($do=="greetings"){ $thesubject = mysql_real_escape_string($_POST['subject']); $themessage = mysql_real_escape_string($_POST['message']); $themessage = wordwrap($themessage,69); $themessage = str_replace("\n.", "\n..", $themessage); $theheader = 'From: info@assesseur.com' . "\r\n"; $theheader.= "Content-Type: text; charset=UNICODE-1-1-UTF-8"; $thedatntime = $dater." ".$timer; $mailresult=mysql_query("SELECT useremail FROM tblmgroup UNION ALL SELECT usermail FROM tblusers WHERE nletter = 1"); $totallist = mysql_num_rows($mailresult); $mailedok = 0; $mailedno = 0; while($mailrs = mysql_fetch_array($mailresult)) { $theemail = $mailrs[0]; if(@mail($theemail,$thesubject,$themessage,$theheader)) { $mailedok++; }else{ $mailedno++; } } $thequery = "INSERT INTO tblmlist (subject, message, users, okusers, nousers, sentin, lastadmin) "; $thequery.= "VALUES ('".$thesubject."', '".$themessage."', ".$totallist.", ".$mailedok.", ".$mailedno.", ".time().", ".$userid.")"; mysql_query("$thequery", $db); if(mysql_errno()==0) { $dbsave = 1; }else{ $dbsave = 0; } if($mailedok>0) { header ("Location: maillist.php?stat=mailok&ok=$mailedok&no=$mailedno&db=$dbsave"); break; }else{ header ("Location: maillist.php?stat=no&ok=$mailedok&no=$mailedno&db=$dbsave"); break; } }elseif($do=="deletepic"){ $the_item = mysql_real_escape_string($_POST['item']); $the_image = mysql_fetch_array(mysql_query("SELECT filename FROM tblmgcards WHERE gid = ".$the_item)); $the_file = $the_image[0]; $laquery = "DELETE FROM tblmgcards WHERE gid =".$the_item; mysql_query("$laquery", $db); if(mysql_errno()==0) { @unlink('../cards/'.$the_file); header ("Location: maillist.php?do=gallery&stat=deleted"); break; }else{ header ("Location: maillist.php?do=gallery&stat=no"); break; } }elseif($do=="delete"){ $item_id = mysql_real_escape_string($_POST['item']); $laquery = "DELETE FROM tblmgroup WHERE id=".$item_id; mysql_query("$laquery", $db); if(mysql_errno()==0) { mysql_close($db); header("Location: maillist.php?stat=deleted"); break; }else{ mysql_close($db); header("Location: maillist.php?stat=error"); break; } }else{ mysql_close(); header("Location: main.php"); } }else{ mysql_close(); header("Location: main.php"); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/289391-mailing-list-problem/ Share on other sites More sharing options...
ginerjm Posted July 3, 2014 Share Posted July 3, 2014 (edited) 1 - It would be nice if you had read the rules and learned how to post your code here properly 2 - It would be nicer if you commented your code so we could follow your thought process 3 - It would be even nicer still if you could indent your code to make it easier to follow and read. 4 - read up on sql syntax. String values have to be in quotes since you are not using prepared queries 5 - while reading manuals, read the php one re: the MySQL_* functions. They are deprecated, ie, don't use them. This code is really bizarre: if(!(($_SESSION['AssessuerSess']=="done"))) { Try this instead - much easier to write and understand. No inverse logic and only one set of parens, not 3. if ($_SESSION['AssessuerSess'] != "done") { Edited July 3, 2014 by ginerjm 1 Quote Link to comment https://forums.phpfreaks.com/topic/289391-mailing-list-problem/#findComment-1483730 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.