I have a form where the name and details are filled and iam able to collect the details filled and email the data.But in the form one field is filled from DB which is "comments" field.
<?php
$sql = "SELECT * FROM comments WHERE 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 will be number of comments but here only one recent comment is getting inserted into the mail.I need all the comments in the db for particular post id table to be inserted into the mail body.PHP code which iam using to send the email:
<?php
if(isset($_POST['email'])) {
$email_to = mail@domain.com;
$email_subject = omments;
function died($error) {
echo "We are very sorry, but there were error(s) found with the form you 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)."
";
// create email headers
$headers = 'From: '.$email_from."
".
'X-Mailer: PHP/' . phpversion();
@mail($email_to, $email_subject, $email_message, $headers);
?>
<?php
}
?>
Can anyone help this one out.Thanks in advance