Jump to content

Swapnil_0226

New Members
  • Posts

    2
  • Joined

  • Last visited

Swapnil_0226's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. This code sends email to different user after selecting checkbox on click of send button. Its work well. here i will send email to different user so in $messege i have to put name of that user so how is it possible. because i m fetching data from database.
  2. <script type="text/javascript"> function send_email(){ var persons_names; persons_names = $('#send_mail_persons input:checked'); var persons_names_Str='',coma=''; if(persons_names.length != 0) { persons_names.each(function(){ persons_names_Str += coma+$(this).val(); coma = ','; }) } alert(persons_names_Str); // console.log(" persons_names_Str: "+persons_names_Str); ajax_call_to_send_values_to(persons_names_Str); } function ajax_call_to_send_values_to(persons_names_Str){ $.ajax({ url: 'http://<?php echo $_SERVER['HTTP_HOST'].$_SERVER['REQUEST_URI'];?>', type: 'POST', data: { persons_names_Str: persons_names_Str }, success: function(data, textStatus, xhr) { }, //called when successful error: function(xhr, textStatus, errorThrown) { //called when there is an error } }); } </script> <div id="send_mail_persons"> <?php $sql = "SELECT * FROM lawyer_details WHERE city LIKE :city AND speciality LIKE :speciality"; $result = db_query($sql,array(':city' => '%'. db_like($_SESSION['selected_county']).'%' , ':speciality' => '%'.db_like($_SESSION['lawarea']).'%')); $rows_count=$result->rowCount(); if($result && $rows_count>0) { while($row = $result->fetchAssoc()) { ?> <div class="result"> <div class="resultPadder"> <div class="resultLeft"> <div id="fav"> <div><input type="checkbox" name="checkbox[]" id="email1" value=<?php echo $row['email_id'];?> /><a class="b ui-link" href="" onclick=""><?php echo $row['first_name'].' '.$row['middle_name'].' '.$row['last_name'];?></a> </div> <div class="p-t-2"><?php echo $row['street_address'];?></div> </div> </div> <?php if( isset($_POST['persons_names_Str']) && !empty($_POST['persons_names_Str']) ) { $list = $_POST['persons_names_Str']; //print_r($list); //$to_arr = explode(",", $list); //$to = array_filter($to_arr); //echo $to; //print_r($to); $to = $list; $subject = "Test Subject"; $message = "Dear attorney ".<?php echo $row['first_name'].' '.$row['middle_name'].' '.$row['last_name'];?>:." If you decide you do not want your name listed, please e-mail us and we will delete your name from our listing.\r\n"; $headers = "From: no-reply@xyz.com\r\n" . "X-Mailer: php"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; $to = "no-reply@xyz.com"; $headerFields = array('BCC: '.$list.', "From: no-reply@lxyz.com" ."X-Mailer: php"'); if (mail($to, $subject, $message, implode("\r\n", $headerFields))) { //if (mail($to, $subject, $body, $headers)) { echo("<p>Message sent successfully! our lawyer will contact you as soon as possible</p>"); } else { echo("<p>Message delivery failed...</p>"); } exit(); } ?> <div class="resultRight"> </div></div><div class="clear"></div> <?php } } else { echo "No Result Found"; } ?> <a href="javascript:void(0);" onClick="javascript:send_email();"><span>Send Email</span></a> </div> </div> <div>
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.