doureng1083 2011-05-22 16:45
浏览 489
已采纳

通过电子邮件发送HTML表单提交时包含标签值

I've created a dynamic HTML form that uses jQuery and customizes the form fields and labels based on the users' input.

In addition to passing the form field values to the $_POST[] array, is there also a simple way to pass the label values? I need to turn the form submission into an email, and the email should include the same label names that appeared on the form. I've contemplated using hidden input fields, but that doesn't seem like an ideal option.

Any ideas?

  • 写回答

3条回答 默认 最新

  • dpqjvoq9033 2011-05-22 16:58
    关注

    There is no use in sending those label texts around. It is unnecessary traffic, and one more thing that needs to be filtered/validated.

    You create the form on the server side, so you already have access to the texts of the labels there. I'd advise you to store these texts in constants, like:

    define('TEXT_EMAIL', 'Email Address');
    

    So when you create the form, you can just type:

    <label for="email"><?=TEXT_EMAIL?></label>
    

    and use the same constant (TEXT_EMAIL and the others) when you build the email body. This way, you will also be in an easy situation if you need to add support for other languages.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料