简体   繁体   English

如何从PHP表格中获取文本并通过mailto链接在电子邮件主题中显示该文本

[英]How to get text from a table in PHP and display that text in the subject of an email via mailto link

I have a form on a website that contains a table with a title and a reference. 我在网站上有一个表格,其中包含带有标题和参考的表格。 At the bottom of this form I have a submit button that I want to create a mailto link that opens up an email with the "From" field auto filled with the users email address that they have entered in the form. 在此表单的底部,我有一个提交按钮,我想创建一个mailto链接,该链接打开一封电子邮件,其中“发件人”字段自动填充了用户在表单中输入的电子邮件地址。 I would also like to auto fill the "Subject" field with the title and reference elements from the table on the form. 我还想用表格上表格的标题和参考元素自动填充“主题”字段。

Could someone please tell me how to go about this using PHP? 有人可以告诉我如何使用PHP进行此操作吗?

See also Mailto Syntax Tutorial . 另请参见Mailto语法教程

When generating this link, you will need to use the same PHP statements you use in the table. 生成此链接时,您将需要使用与表中相同的PHP语句。

Because you haven't provided any code, here's a general approach to the matter. 由于您尚未提供任何代码,因此这是解决此问题的通用方法。

Say for example, your table is populated 假设您的表格已填充

<table>
  <tr>
    <td>Title:</td>
    <td><?php echo $data['title']; ?></td>
  </tr>
  <tr>
    <td>Reference:</td>
    <td><?php echo $data['ref']; ?></td>
  </tr>
</table>

You would have to create the link: 您将必须创建链接:

<a href="mailto:email@domein.com?subject=<?php echo $data['title']; ?> - ref. <?php echo $data['ref']; ?>">Send mail</a>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM