static function multi_attach_mail($to, $subject, $message_body, $files, $sendermail,$cc="",$bcc=""){ $message_body = '<html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>Edify Email</title><body>'.$message_body.'</body></head></html>'; // email fields: to, from, subject, and so on //$sendermail = "heenabhalla007@gmail.com"; $from = "<".$sendermail.">"; //$subject = date("d.M H:i")." F=".count($files); $message = date("Y.m.d H:i:s")."\n".count($files)." attachments"; $headers = "From: $from \r\n"; if($cc !=""){ //$cc = "<".$cc.">"; $headers .= "Cc: $cc \r\n"; } if($bcc !=""){ //$bcc = "<".$bcc.">"; $headers .= "Bcc: $bcc \r\n"; } $headers .= "Reply-To: $sendermail \r\n"; $headers .= "X-Mailer: PHP/".phpversion(); // boundary $semi_rand = md5(time()); $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $message = "--{$mime_boundary}\n" . "Content-Type: text/html; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message_body . "\n\n"; // preparing attachments for($i=0;$i<count($files);$i++){ if(is_file($files[$i])){ $message .= "--{$mime_boundary}\n"; $fp = @fopen($files[$i],"rb"); $data = @fread($fp,filesize($files[$i])); @fclose($fp); $data = chunk_split(base64_encode($data)); $message .= "Content-Type: application/octet-stream; name=\"".basename($files[$i])."\"\n" . "Content-Description: ".basename($files[$i])."\n" . "Content-Disposition: attachment;\n" . " filename=\"".basename($files[$i])."\"; size=".filesize($files[$i]).";\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; } } $message .= "--{$mime_boundary}--"; $returnpath = "-f" . $sendermail; @mail($to, $subject, $message, $headers, $returnpath); }
multi delete
////////////////////////////// For deleting multiple row ///////////////////////////////////////////// $('.dependent_delete').live("click",function(){ if(confirm('Are you sure! You want to delete')){ var dependent_id = $(this).attr("title"); if(dependent_id){ var form_data = {'dependent_id' : dependent_id }; $.ajax({ async: false, type: "POST", url: site_url+"/modules/student/index.php?page=ajax_actions&action_page=delete_dependent_brp&action=delete", data: form_data, success: function(result){ //alert(result); //$('#dependent_'+dependent_id).remove(); } }); } $(this).parent().parent().remove(); } return false; });
Dynamic variable
${$_REQUEST['email_2']} here if $_REQUEST['email_2'] value is car then dynamic variable value will be $car
Edit and Update multiple row
///////////////////////////// Edit and Update coding ///////////////////////////////////////////////////////////////// if(isset($_REQUEST['dependent_name'])){ foreach($_REQUEST['dependent_name'] as $key=>$val){ if(is_array($_REQUEST['dependent_name'][$key])){ foreach($_REQUEST['dependent_name'][$key] as $k=>$v){ //echo $key."------->".$val."<br>"; $dependenet_id = $k; $dependent_name = $_REQUEST['dependent_name'][$key][$k]; $dependent_date_of_birth = ($_REQUEST['dependent_date_of_birth'][$key][$k] == '') ? '' : StringUtility::setFormatedDateBritish($_REQUEST['dependent_date_of_birth'][$key][$k]); $query = "UPDATE student_brp_dependent SET dependent_name = '".$dependent_name."', dependent_date_of_birth = '".$dependent_date_of_birth."' WHERE id = '".$dependenet_id."'"; mysql_query($query); } }else{ $dependent_name = $_REQUEST['dependent_name'][$key]; $dependent_date_of_birth = ($_REQUEST['dependent_date_of_birth'][$key] == '') ? '' : StringUtility::setFormatedDateBritish($_REQUEST['dependent_date_of_birth'][$key]); $query = "INSERT INTO student_brp_dependent(brp_id,dependent_name,dependent_date_of_birth) VALUES('".$brp_id."','".$dependent_name."','".$dependent_date_of_birth."')"; mysql_query($query); } } } //////////////////////////////////////// End edit and update coding ///////////////////////////////////////////// <!-------------------- HTML code for multiple row -----------------------------> <h2>Dependants</h2> <table id="dependants_table" border=1;> <tr valign="top"> <td style="font-weight:bold" width="10%"> Dependant Name: </td> <td style="font-weight:bold" width="10%"> Dependant Date of birth: </td> </tr> <?php if($brp_id >0){ while($row_edit = mysql_fetch_array($result_edit)){ $dependent_id = $row_edit['id']; $dependent_name = $row_edit['dependent_name']; $dependent_date_of_birth = $row_edit['dependent_date_of_birth']; ?> <tr> <td> <input type='text' style='width:80px;' class='dependent_name' name='dependent_name[][<?=$dependent_id;?>]' value='<?php echo $dependent_name; ?>'/> </td> <td> <input type='text' style='width:80px;' class='dependent_date_of_birth' name='dependent_date_of_birth[][<?=$dependent_id;?>]' value='<?php echo ($dependent_date_of_birth) ? StringUtility::getFormatedDateBritish($dependent_date_of_birth) : ""; ?>'/> </td> </tr> <?php } }?> </table> <div id="multi_row" style="float:left;margin-left:20px;cursor:pointer;border:0px solid red;">Add New Row (+)</div><br><br> <!-------------------- End HTML code -------------------------> //////////////////////////////// Java script code for multiple row //////////////////////////////////////////// $('.dependent_date_of_birth').live('focus', function() { $(this).datepicker({ changeMonth: true, changeYear: true, dateFormat: 'dd-mm-yy', yearRange: (new Date().getFullYear()-100)+ ':' + (new Date().getFullYear()+10), onSelect: function(){ } }).datepicker('show'); true; }); $('#multi_row').click(function(){ var dependent_name = "<input type='text' style='width:80px;' class='dependent_name' name='dependent_name[]'/>"; var dependent_date_of_birth = "<input type='text' style='width:80px;' class='dependent_date_of_birth' name='dependent_date_of_birth[]'/>"; var new_row_for_apply = "<tr><td>"+dependent_name+"</td><td>"+dependent_date_of_birth+"</td></tr>"; $("#dependants_table").append(new_row_for_apply); }); ////////////////////////////// end java script code //////////////////////////////////////////////////////////////