Kashmenon Posted October 6, 2015 Share Posted October 6, 2015 (edited) Hi I have been struggling to get this option incorporated into the following code Requirement :- What should I do to select the emails in the following image and email them all directly from outlook with mail() option. They should have checkboxes next to them or some other method with which we can select them. The emails are all stored in an SQL Database. Please do let me know. Thank you for all the help in advance. <?php include("includes/header.php"); include("../../lib/master_include.php"); require_once('includes/pagination.php'); $modelCatJs = array(); //Use for checkbox checked on form submit $fsexVal = ''; if(isset($_GET['del_model_id'])){ //$HTTP_HOST = $_SERVER["HTTP_HOST"]; //if ($HTTP_HOST == "localhost") { //$con=mysqli_connect("localhost","user","pass","db"); //} //if ($HTTP_HOST == "website" || $HTTP_HOST == "website") { $con=mysql_connect("localhost","user","pass"); mysql_select_db("db", $con); //} if($_SESSION['LateItWebAdmin']['sID']==1) { mysql_query("DELETE FROM model_data WHERE fmodel_id = '".$_GET['del_model_id']."'"); //$obj->Query("DELETE FROM model_data WHERE fmodel_id = '".$_GET['del_model_id']."'"); $select_images_models = $obj->selectQuery("SELECT * FROM model_image WHERE fmodel_id = '".$_GET['del_model_id']."'"); while($row_model_images = mysql_fetch_array($select_images_models)){ unlink('../../model/'.$row_model_images['image_name']); } //$obj->Query("DELETE FROM model_image WHERE fmodel_id = '".$_GET['del_model_id']."'"); $qury = mysql_query("DELETE FROM model_image WHERE fmodel_id = '".$_GET['del_model_id']."'"); //print_r($qury); echo 'Record Deleted'; } else { echo "You can't delete any model information."; } } //Pagination if(!isset($_REQUEST['page'])){ $page = 1; }else{ $page = $_REQUEST['page']; } if(!isset($_REQUEST['start'])){ $start = 0; }else{ $start = $_REQUEST['start']; } $perpage = 20; $start=($page-1)*$perpage; $seldata = $obj->selectQuery("SELECT * FROM model_data"); $RecordCount = mysql_num_rows($seldata); //End Pagination if(isset($_REQUEST['searchbtn'])){ (!empty($_REQUEST['fmodel_id'])) ? $_REQUEST['fmodel_id'] = $_REQUEST['fmodel_id']: $_REQUEST['fmodel_id'] = ''; (!empty($_REQUEST['searchbtn'])) ? $_REQUEST['searchbtn'] = $_REQUEST['searchbtn'] : $_REQUEST['searchbtn'] = ''; $search_name = $_REQUEST['search_name']; $fsex1 = $_REQUEST['fsex1']; $where = " AND ffirst_name LIKE '%$search_name%' AND fsex LIKE '%$fsex1%'"; $search_for_divacat = $_REQUEST['search_for_divacat']; if(!empty($search_for_divacat)){ $where .= "AND fdiva_cat = '$search_for_divacat'"; } $search_by = $_REQUEST['search_by_dd']; $search_val = trim($_REQUEST['search_val'], ' '); if($search_val=='african' || $search_val == 'African') { $ethen_id = 6; } else if($search_val=='Arabic' || $search_val == 'arabic') { $ethen_id = 13; } else if($search_val=='European' || $search_val == 'european') { $ethen_id = 5; } else if($search_val=='Indian' || $search_val == 'indian') { $ethen_id = 2; } else if($search_val=='Mediterranean' || $search_val == 'mediterranean') { $ethen_id = 26; } else if($search_val=='Oriental' || $search_val == 'oriental') { $ethen_id = 4; } switch($search_by){ case "fsearch_all": //echo "SELECT * FROM model_data WHERE ffirst_name LIKE '%$search_name%' $where"; $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE ffirst_name LIKE '%$search_name%' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE ffirst_name LIKE '%$search_name%' $where ORDER BY ffirst_name ASC Limit $start, $perpage"); break; case "fmodel_id": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE id LIKE '%$search_val%' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE id LIKE '%$search_val%' $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break; case "fethnicity": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE feth_id='$ethen_id' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE feth_id='$ethen_id' $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break; /*case "fsex": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE fsex LIKE '%$search_val%' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE fsex LIKE '%$search_val%' $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break;*/ /*case "ffname": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE ffirst_name LIKE '%$search_val%' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE ffirst_name LIKE '%$search_val%' $where ORDER BY ffirst_name ASC Limit $start, $perpage"); break;*/ case "femail": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE femail LIKE '%$search_val%' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE femail LIKE '%$search_val%' $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break; case "fcontact_no": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE (fcontact_no LIKE '%$search_val%' OR fmobile LIKE '%$search_val%') $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE (fcontact_no LIKE '%$search_val%' OR fmobile LIKE '%$search_val%') $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break; case "fnation": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE (fnation LIKE '%$search_val%') $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE (fnation LIKE '%$search_val%') $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break; case "fcity": $seldata_num = $obj->selectQuery("SELECT * FROM model_data WHERE fcity LIKE '%$search_val%' $where"); $seldata = $obj->selectQuery("SELECT * FROM model_data WHERE fcity LIKE '%$search_val%' $where ORDER BY fmodel_id DESC Limit $start, $perpage"); break; default: echo 'Not a valid condition'; } } else { unset($_REQUEST); if(isset($_GET['type']) && $_GET['type']=='active'){ $seldata = $obj->selectQuery("SELECT * FROM model_data where fstatus = 'Y' ORDER BY fmodel_id DESC Limit $start, $perpage"); }elseif(isset($_GET['type']) && $_GET['type']=='in-active'){ $seldata = $obj->selectQuery("SELECT * FROM model_data fstatus = 'N' ORDER BY fmodel_id DESC Limit $start, $perpage"); }else{ $seldata_num = $obj->selectQuery("SELECT * FROM model_data"); $seldata = $obj->selectQuery("SELECT * FROM model_data ORDER BY id DESC Limit $start, $perpage"); } } $RecordCount = mysql_num_rows($seldata_num); if (isset($_POST['btn_del'])) { $req = $_POST['del_id']; // $id = $_POST['id']; for ($i=0; $i<count($req); $i++) { if ($req[$i]) { // $res = $obj->Query("DELETE FROM model_data WHERE fmodel_id = '".$req[$i]."'"); $res = $obj->Query("DELETE FROM model_data WHERE id = '".$req[$i]."'"); $res1 = $obj->Query("DELETE FROM model_image WHERE fmodel_id = '".$req[$i]."'"); $imgpath = $obj->selectQuery("select image_name FROM model_image WHERE fmodel_id = '".$req[$i]."'"); $img_rows = mysql_fetch_array($imgpath); exit; for($j=0; $j < count($img_rows); $j++) { $path = "../model/".$img_rows[$j]; unlink($path); } //$res = $cms_page->delete_page($req[$i]); if($res === false){ $errors .= 'This page Could not be deleted.<br>'; } //clearAllCacheFromAdmin(); } } if($errors == ''){ $msg = urlencode("Record_deleted_successfully"); } else{ $msg = urlencode($errors); } header("Location: manage_models.php?msg=$msg"); } if (isset($_POST['update_order'])) { $sort = $_POST['sort']; $id = $_POST['id']; for ($i=0; $i<count($sort); $i++) { if ($sort[$i]) { $res = $obj->Query("UPDATE web_faq SET faq_order = '".abs(round($sort[$i]))."' WHERE faqID = '".$id[$i]."'"); // $res = $cms_page->update_sort_order(abs(round($sort[$i])), $id[$i]); if($res === false){ $errors .= 'This page Could not be updated.<br>'; } //clearAllCacheFromAdmin(); } } if($errors == ''){ $msg = urlencode("Record_Updated_Successfully"); } else{ $msg = urlencode($errors); } header("Location: manage_faq.php?msg=$msg"); } ?> <style type="text/css"> #navigat { color: #000000; font: 14px/24px sans-serif; margin: 0 auto; padding: 0; width: 100%; float:left; margin-bottom:15px; } #navigat .btn { border-radius: 5px 5px 5px 5px; color: #000000; display: inline-block; font-size: 0.875em; padding: 10px; } #navigat .paginat { float: right; margin-bottom: 0; padding: 0; } #navigat .page { background: none repeat scroll 0 0 #E9E9E9; border: 1px solid #c6c6c6; border-radius: 3px 3px 3px 3px; box-shadow: 0 1px 0 rgba(255, 255, 255, 0. inset, 0 1px 3px rgba(0, 0, 0, 0.1); color: #000000; display: inline-block; font-size: 0.875em; font-weight: bold; margin-right: 4px; padding: 0 9px; text-decoration: none; text-shadow: 0 1px 0 #FFFFFF; } #navigat .page:hover, #navigat .page.gradient:hover { background: none repeat scroll 0 0 #333333; border: 1px solid #333333; color: #FFFFFF; } #navigat .page.active { background: none repeat scroll 0 0 #333333; border: medium none; box-shadow: 0 0 8px rgba(0, 0, 0, 0.5) inset, 0 1px 0 rgba(255, 255, 255, 0. ; color: #F0F0F0; text-shadow: 0 0 3px rgba(0, 0, 0, 0.5); } #navigat .page.gradient { background: none repeat scroll 0 0 #c6c6c6; } </style> <?php if(isset($_GET['msg'])){ ?><div class="n_ok"><p><?php echo str_replace("_"," ",$_GET['msg']); ?></p></div><?php } ?> <div class="entry" style="float:left; margin-left:10px;"> <form action="" method="get" name="sfrm" id="sfrm" > <div class="rt"> <?php /*?> <select name="blocked_mod" id="blocked_mod" onchange="change_stat();" > <option <?php if(isset($_GET['type']) && $_GET['type']=='all'){ echo 'selected="selected"';} ?> value="all">All</option> <option <?php if(isset($_GET['type']) && $_GET['type']=='active'){ echo 'selected="selected"';} ?> value="active">Active</option> <option <?php if(isset($_GET['type']) && $_GET['type']=='in-active'){ echo 'selected="selected"';} ?> value="in-active">In-Active</option> </select><?php */?> <div class="chkBobexs"> <table class='tabwhite' border="0" width="600"cellpadding="0" cellspacing="0"> <tr> <td class='yl_tb'> </td> <td class='yl_tb' height='25' align="right">Search For</td> <td class='yl_tb1' style="padding-left:14px"> <select size="1" name="search_for_divacat" id="search_for_divacat" style="width:195px;"> <option value="">Search For All</option> <option value="1"> MODELS </option> <option value="2"> PROMOTERS </option> <option value="3"> CAST </option> <option value="4"> STYLISTS </option> <option value="5"> LOCATIONS </option> <option value="6"> PHOTOGRAPHERS </option> <option value="7"> ENTERTAINERS </option> <option value="8"> EVENTS </option> <option value="9"> PUBLIC RELATIONS </option> <option value="10"> PRODUCTION </option> <option value="11"> STOCK IMAGES </option> <option value="12"> OUR WORK </option> <option value="13"> DIRECTORS </option> <option value="14"> AWARDS </option> </select> </td> </tr> <tr> <td class='yl_tb'> </td> <td class='yl_tb' height='25' align="right">Gender</td> <td class='yl_tb1' style="padding-left:14px"> <select size="1" name="fsex1" class="yl_tb2" style="width:195px;" id="fsex1"> <option value="">All</option> <option value="M">Male</option> <option value="F">Female</option> <option value="B">Boy</option> <option value="G">Girl</option> </select> </td> </tr> <tr> <td class='yl_tb'> </td> <td class='yl_tb' height='25' align="right">Name</td> <td style="padding-left:14px"><input type="text" name="search_name" value=""></td> </tr> <tr> <td class='yl_tb'> </td> <td class='yl_tb' height='25' align="right">Search By</td> <td class='yl_tb1' style="padding-left:14px"> <select size="1" name="search_by_dd" id="search_by_dd" style="width:195px;"> <option value="fsearch_all">Search for All</option> <option value="fmodel_id">ID</option> <option value="fethnicity">Ethnicity</option> <!--<option value='fsex'>Gender</option>--> <!--<option value='ffname'>Name</option>--> <option value='femail'>Email</option> <option value='fcontact_no'>Contact Number</option> <option value='fcity'>City</option> <option value='fnation'>Nationality</option> <option value='fage'>Age</option> </select> </td> </tr> <tr> <td width="15"> </td> <td width="66" class='yl_tb' height='25' align="right">Search Value</font></td> <td style="padding-left:14px" id="search_by"> <input type="text" name="search_val" class="number" placeholder="" /> </td> </tr> <tr> <td class='yl_tb'> </td> <td class='yl_tb'> <td class='yl_tb'><div align="right" style="padding-right:70px"> <input name="searchbtn" type="submit" class="" id="searchbtn" value="Search" style="cursor:pointer;" /> </div></td> </tr> </table> </div> </div> </form> </div> <form name="form1" class="serach_form" id="form1" method="post" action=""> <div class="entry"> <div class="sep"></div> <div class="rt"> <a class="button add" href="add_new_model.php">Add New Model</a> <?php /*?><?php if($_SESSION['LateItWebAdmin']['username']=='superadmin' || $_SESSION['LateItWebAdmin']['sID']== 1 || $_SESSION['LateItWebAdmin']['username']=='Nicole') { if($RecordCount>0){ ?> <input name="btn_del" class="cancel Button" type="submit" id="btn_del" onclick="return validate_msg('Select any checkbox to delete','Are you sure you want to delete this Record?');" value="Delete Selected" /> <?php } } ?><?php */?> </div> </div> <div style="clear:both"></div> <?php if($RecordCount>0){ ?> <table width="100%"> <thead> <tr> <th width="5%" >ID</th> <th width="10%" >Image</th> <th width="10%" >Detail</th> <th width="10%" >Gender</th> <th width="5%" >Category</th> <th width="10%" >Nationality</th> <th width="15%" >Modify</th> </tr> </thead> <tbody> <?php while($rowfe = mysql_fetch_array($seldata)) { ?> <?php ?> <tr> <td align="center"><?php echo $rowfe['id']; ?></td> <td align="center"><?php $imageseldata = $obj->selectQuery("SELECT * FROM model_image WHERE fmodel_id = '".$rowfe['fmodel_id']."' ORDER BY disp_priority DESC LIMIT 1"); $i_row = mysql_fetch_array($imageseldata); if($i_row['image_name'] != '') { ?> <a href="http://divadubai.com/search_detail.php?mod_id=<?=$rowfe['fmodel_id']?>&search_for=models&category=1" target="_blank"><img src="../../model/<?php echo $i_row['image_name']; ?>" height="60" width="60" /></a> <?php } else{ ?> <a href="http://divadubai.com/search_detail.php?mod_id=<?=$rowfe['fmodel_id']?>&search_for=events&category=1" target="_blank"><img src="../images/60x60.gif" height="60" width="60" /></a> <?php } ?> </td> <td align="center"> <table> <tr><td>Name: <a href="model_detail.php?id=<?php echo $rowfe['id']; ?>"><?php echo $rowfe['ffirst_name'].' '.$rowfe['flast_name']; ?> </a> </td> </tr> <tr><td>Email: <?php echo $rowfe['femail']; ?></td> </tr> <?php $dobyear = date('Y',strtotime($rowfe['fdateofbirth'])); $curyear = date('Y'); $ages = $curyear - $dobyear;?> <tr><td>Age:<?php echo $ages.'{'.$rowfe['fdateofbirth'].'}'; ?></td> </tr> <tr><td>Mobile: <?php if(!empty($rowfe['fmobile_no'])) echo $rowfe['fmobile_no']; else echo $rowfe['fmobile']; ?></td></tr> </table> </td> <td align="center"><?php if($rowfe['fsex']=='F'){ echo 'Female';}elseif($rowfe['fsex']=='ma' || $rowfe['fsex']=='m' || $rowfe['fsex']=='M'){ echo 'Male';}elseif($rowfe['fsex']=='G'){ echo 'Girl'; }elseif($rowfe['fsex']=='B'){ echo 'Boy'; } ?></td> <td align="center"><?php echo $rowfe['fdiva_cat']; ?></td> <td align="center"><?php echo $rowfe['fnation']; ?></td> <td> <a href="../../preview.php?mid=<?php echo $rowfe['id'];?>&catid=<?php echo $rowfe['fdiva_cat']; ?>" target="_blank">Preview</a><br /> <a href="add_new_model_edit.php?id=<?php echo $rowfe['id'];?>" class="table-icon edit" title="Edit"></a> <a href="edit_model_image.php?id=<?php echo $rowfe['fmodel_id'];?>" class="edit" title="Edit Image">Edit Image</a> <br /> <a href="?del_model_id=<?php echo $rowfe['fmodel_id'];?>" onclick="return confirm('Really delete?');">Delete Record?</a> </td> </tr> <?php } ?> </tbody> </table> <?php } else { echo ' <div class="entry">'; echo '<div class="n_warning"><p>No Record Found!</p></div></div'; }?> </form> <?php if(isset($_REQUEST['searchbtn'])){ /*echo pagination($perpage,$page, 'http://divadubai.com/new_admin/div-admin/manage_models.php?blocked_mod='.$_REQUEST['blocked_mod'].'&search_for_divacat='.$_REQUEST['search_for_divacat'].'&search_by_dd='.$_REQUEST['search_by_dd'].'&fmodel_id='.$_REQUEST['fmodel_id'].'&search_val='.$_REQUEST['search_val'].'&fcity='.$_REQUEST['fcity'].'&searchbtn=Serach&start='.$start.'&perpage='.$perpage.'&page=',$RecordCount);*/ //call function to show pagination echo pagination($perpage,$page, 'http://divadubai.com/admin/admin/manage_models.php?search_for_divacat='.$_REQUEST['search_for_divacat'].'&fsex1='.$fsex1.'&search_name='.$search_name.'&search_by_dd='.$_REQUEST['search_by_dd'].'&fsearch_all=&search_val='.$_REQUEST['search_val'].'&searchbtn=Serach&start='.$start.'&perpage='.$perpage.'&page=',$RecordCount); }else{ echo pagination($perpage,$page, 'http://divadubai.com/admin/admin/manage_models.php?start='.$start.'&perpage='.$perpage.'&page=',$RecordCount); //call function to show pagination } ?> </div> </div> <div class="clear"></div> </div> </div> </div> </div> </div> <?php $nationality = $obj->selectQuery("SELECT DISTINCT fnation FROM model_data ORDER BY fnation ASC"); $nationality_html = '<select name="search_val">'; while($nationality_res = mysql_fetch_object($nationality )){ $nationality_html .= '<option value="'.$nationality_res->fnation.'">'.$nationality_res->fnation.'</option>'; } $nationality_html .= '</select>'; ?> <script type="text/javascript" language="javascript"> function change_stat(){ var val = $('#blocked_mod').val(); var url = '<?php echo 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI']; ?>'+'?type='+val; window.location.href = url; } $(document).ready(function(){ $('#search_by_dd').change(function(){ var search_by = $(this).val(); if(search_by == 'fsearch_all'){ $('#search_by').html('<input type="text" name="search_val" class="" placeholder="" />'); } else if(search_by == 'fmodel_id'){ $('#search_by').html('<input type="text" name="search_val" class="required number" placeholder="Enter Model Id" required="required" />'); }else if(search_by == 'ffname'){ $('#search_by').html('<input type="text" name="search_val" class="required" placeholder="Enter Model Name" required="required" />'); }else if(search_by == 'femail'){ $('#search_by').html('<input type="text" name="search_val" class="required email" placeholder="Enter Model email" required="required" />'); }else if(search_by == 'fcontact_no'){ $('#search_by').html('<input type="text" name="search_val" class="required" placeholder="Enter Model Contact Number" required="required" />'); }else if(search_by == 'fnation'){ $('#search_by').html('<input type="text" name="search_val" class="required" placeholder="Enter Model Nationality" required="required" />'); }else if(search_by == 'fsex'){ $('#search_by').html('<select size="1" name="search_val" class="yl_tb2 valid" style="width:195px;" id="fsex"><option value="">All</option><option value="M">Male</option><option value="F">Female</option><option value="B">Boy</option><option value="G">Girl</option></select>'); }else if(search_by == 'fcity'){ $('#search_by').html('<input type="text" name="search_val" class="required" placeholder="Enter Model City" required="required" />'); } }); $('#fsex').val('<?=$fsexVal?>'); var fsexLoad = $('#fsex').val('<?=$fsexVal?>'); $('#fsex').change(function(){ var fsexVal = $('#fsex').val(); if(fsexVal == 'B' || fsexVal == 'G'){ $('#ageGender').slideDown('fast'); }else{ $('#ageGender').slideUp('fast'); $('#fage').val(''); } }); }); </script> <?php include("includes/footer.php"); ?> Edited October 7, 2015 by cyberRobot added code tags Quote Link to comment https://forums.phpfreaks.com/topic/298453-select-emails-and-mail-them-some-body-altogether/ Share on other sites More sharing options...
Solution seandisanti Posted October 7, 2015 Solution Share Posted October 7, 2015 Ok, here's what I think I'm reading in your request... You have a list of messages on an admin page and you would like the ability to select some of them, and respond to them all at once from your chosen email client, is that correct? Before I try to answer that, there are a few things you should do either way. 1) use code tags [ code] and [ /code] (without spaces) around your code to make it easier to read 2) look into using PDO or mysqli_ instead of deprecated mysql extension. Assuming you take care of both of those, that still leaves your main problem. One way to kind of achieve that, would be to write an ajax call that returns a delimited list of email addresses based on the checked checkboxes which can be thrown into a 'mailto' link, and a new window opened with that link. Depending on how you have your system configured, specifically regarding default apps and behaviors, that could open a new mail message in outlook with the addresses already entered. I would consider that approach far less than optimal though as it's not guaranteed to work on every (or any) system you may use. A better approach I think would be to scrap the idea of opening it in a local client to compose the mail, and just write the response functionality yourself. You could do a simple message form in a jquery modal dialog, have the recipients populated based on checked checkboxes, then a text field to type your message in and a button each to send or cancel. Then have the server send the message either with a site email, or whatever email account you configure. Quote Link to comment https://forums.phpfreaks.com/topic/298453-select-emails-and-mail-them-some-body-altogether/#findComment-1522536 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.