php - emailing form data filled from db -
i have form name , details filled , iam able collect details filled , email data.but in form 1 field filled db "comments" field.
<?php $sql = "select * comments id = no "; $result = mysqli_query ($conn,$sql) or die (mysqli_error ()); $count = 1; while ($row = mysqli_fetch_array ($result)) {?> <tr> <td valign="top" > <label for="old_comments">comments <?php echo $count ?>:</label> </td> <td style=" padding-bottom: 0px;"> <input type="text" name="old_comments" value="<?php echo $row ['updates']; ?> " readonly maxlength="500" size="30" style=" width: 710px; "> <br> <span class="helptext" >previous comments.</span> </td> </tr> <?php $count = $count + 1; } ?>
there number of comments here 1 recent comment getting inserted mail.i need comments in db particular post id table inserted mail body.php code iam using send email:
<?php if(isset($_post['email'])) { $email_to = mail@domain.com; $email_subject = omments; function died($error) { echo "we sorry, there error(s) found form submitted. "; die(); } // validation expected data exists if(!isset($_post['old_comments'])) { } $old_comments = $_post['old_comments]; // required $error_message = ""; $email_exp = '/^[a-za-z0-9._%-]+@[a-za-z0-9.-]+\.[a-za-z]{2,4}$/'; $string_exp = "/^[a-za-z .'-]+$/"; if(strlen($error_message) > 0) { died($error_message); } $email_message = "comments"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } $email_message .= "previous comments: ".clean_string($comments)."\n\n"; // create email headers $headers = 'from: '.$email_from."\r\n". 'x-mailer: php/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <?php } ?>
can 1 out.thanks in advance
Comments
Post a Comment