如何在我的php邮件表单中添加图像标题?

时间:2014-11-04 15:13:07

标签: php email

所以我有一个标准化的邮件表格,其中包含必须随附的某些生成的详细信息,包括标题图像 我试图找出如何将图像添加到文本表单中以供我发送时使用 我有

$img_path = 'image12.jpg';  //declaration

  while($row = mysql_fetch_array($result))

{ 
    echo "<tr>";  

    $emailContent=str_replace("\\r\\n","",$row["generic_email_text"]);   
    echo 'Test';
    echo '<td width="450"><textarea name="genericemail">'.$img_path .$emailContent.'</textarea></td>'; 
    echo "</tr>";
}
echo "</tr>";   
echo "</table><p>";     

我尝试添加img_path但它不起作用。我接替了别人的代码,我总觉得很困难。我得到的就是img的名字(“image12”)

是的,我曾经在一段时间内完成了PHP

这是用于提取表单信息的PHP

$fullName = $firstName . " " . $lastName;
    $imageFile = str_replace = '<img src="http://css-tricks.com/examples/WebsiteChangeRequestForm/images/wcrf-header.png" alt="Website Change Request" />';  //Header here is just a place holder
    $updatedEmailText = str_replace("%name%", fieldHtmlFormat($firstName), $updatedEmailText);
    $updatedEmailText = str_replace("%firstname%", fieldHtmlFormat($firstName), $updatedEmailText);
    $updatedEmailText = str_replace("%lastname%", fieldHtmlFormat($lastName), $updatedEmailText);
    $updatedEmailText = str_replace("%duration%", fieldHtmlFormat($durationOfStay), $updatedEmailText);
    $updatedEmailText = str_replace("%destination%", fieldHtmlFormat($arrivalCity), $updatedEmailText); 
    $updatedEmailText = str_replace("%travel%", fieldHtmlFormat($travel), $updatedEmailText);   
    return $updatedEmailText;   .  

编辑:
  改变了代码:

while($row = mysql_fetch_array($result))
    { 
        echo "<tr>";  

        $emailContent=str_replace("\\r\\n","",$row["generic_email_text"]);   
        echo 'Test';
 //LINE 50'<td width="450"><textarea name="genericemail"><imgsrc="'.$img_path.'"/>'.$emailContent.'</textarea></td>'    }//LINE50
    echo "</tr>";   
    echo "</table><p>";

1 个答案:

答案 0 :(得分:1)

您需要添加<img>标记才能显示照片。

替换行:

echo '<td width="450"><textarea name="genericemail">'.$img_path .$emailContent.'</textarea></td>'; 

这一行:

echo '<td width="450"><textarea name="genericemail"><img src="'.$img_path.'"/>'.$emailContent.'</textarea></td>';

并确保您拥有$img_path的正确文件/网址路径。