PHP 表单问题 - 创建允许用户向朋友发送网站信息的表单
编辑-
感谢您的及时回复。具体来说,我想要实现的是设置一个 html 页面,其唯一目的是通过用户填写的表单进行抓取,然后将其放入电子邮件正文中并发送给用户选择的人员。我会将该 html 页面格式化为非常简单。我不知道这是否会进一步缩小范围。
您好,
我必须创建 2 个表单,其中一个是我已完成的典型 php 联系表单,但另一个需要允许用户将网站信息的压缩版本发送给朋友。 “分享此网站”之类的链接。我的客户向我发送了一个示例,您可以在其中输入收件人的电子邮件地址、发件人的电子邮件、姓名和消息,收件人会收到一封包含压缩信息的 html 电子邮件。我不是专家,我终于掌握了基本联系表的窍门。任何帮助将不胜感激。
谢谢你, 詹弗兰科
Edit-
Thank you for your prompt responses. Specifically what I want to achieve is for me to have setup an html page whose sole purpose is to be grabbed by the form the user has filled and is then put inside the body of an email and sent to the person the user has chosen. I would format that html page to be very simple. I don't know if that narrows it down more.
Hi,
I have to create 2 forms one is a typical php contact form which I have completed but the other one needs to allow the user to send a compacted version of the site's information to a friend. "Share this site" kind of link. My client sent me a sample where you input the recipient's email address, the sender's email, name and message and the recipient receives an html email with the compacted information. I am not an expert and I just finally got the hang of the basic contact form. Any help would be greatly appreciated.
Thank you,
Gianfranco
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
更多细节肯定会有所帮助,我不知道您是否想将 $_POST[] 数据的一部分发送给另一个用户,或者实际上与另一个用户共享页面上的内容。
如果您希望触发 $_POST[] 数据(或其中一些数据),只需包含一个循环来构建 var/val 组合并将它们作为处理例程的一部分发送给另一个用户。代码如下:
如果您正在谈论邮寄页面上的内容,我认为只需一个简单的提交即可将链接发送到当前页面将是一个很好的解决方案,特别是因为所有电子邮件客户端以不同的方式呈现 HTML(或根本不呈现),因此发送链接是让人们返回正确内容的可靠方法。
More specifics would definitely help here, I can't figure out if you want to send part of the $_POST[] data to another user or actually share the content on the page w/ another user.
If you wish to fire off the $_POST[] data (or some of it) just include a loop to build up var/val combos and send them off to another user as part of your processing routine. The code for that would be something like this:
If you are talking about mailing the content on the page I think just a simple submit that sends the link to the current page would be a good solution, particularly due to the fact that all email clients render HTML differently (or not at all) so sending a link is a sure fire way to get people back to your proper content.
为此,您需要四件事:
允许输入“发件人电子邮件”、“收件人电子邮件”、“姓名”和“消息”的表单。这还应该包括一些指向他们希望发送的页面的链接(无论这是 URL、ID 等,您只需要某种方法来识别它。被动地将其发送到表单是一个好主意。)您必须决定在何处以及如何显示它(例如,在其自己的页面上、在每个内容页面上、作为弹出窗口、作为悬停框等)。
可以提取相关页面的相关部分以通过电子邮件发送的脚本。例如,如果它只是一个带有标题的图像,您可能只需要图像和标题(而不是标题栏、导航栏或类似的东西)。对于一篇文章,您可能想要发送整个文本,或者您可能只想发送一个片段。我找到了执行此操作的最简单方法,请确保实际内容位于某些类似
$content
的变量中,您可以根据需要对其进行解析。一个电子邮件模板,您可以将第 2 项中的数据注入其中。这可能是一封空白电子邮件,一封与您的网站类似的电子邮件,其中包含您网站的标题、颜色等,或者完全不同的内容。这取决于您。
一个电子邮件脚本,可以将项目 #3 中的电子邮件发送到项目 #1 中的电子邮件,附加事实是该电子邮件必须标记为从“发件人的电子邮件”发送“从步骤#1开始。这可以通过电子邮件标头来完成。
当您完成所有这些步骤后,就相对简单了,从第 1 项中的表单获取必要的数据。给定传递到项目 #1 中表单的标识符,收集步骤 #2 中所需的项目数据。加载电子邮件模板,并将项目#1 和#2 中的数据注入其中,然后构建由项目#1 中的用户详细信息组成的必要标头。然后将此电子邮件发送到项目#4 进行传递。
您问的是一个非常广泛的问题,这是我可以在没有更多细节的情况下回答它的最佳方式。我建议您单独研究其中的每一项,因为这将有助于减少您的工作量并为您提供更多信息灵活、可扩展且健壮的脚本。
You'll need four things for this:
A form that allows the input of "sender's e-mail", "recipient's e-mail", "name" and "message". This should also include some link to the page they wish to send (whether this is a URL, and ID, etc, you just need some way to identify this. It is a good idea to send this passively to the form.) You'll have to decide where and how to display this (for instance, on it's own page, on each content page, as a pop-up, as a hovering box, etc).
A script that can pull relevant parts of the page in question for e-mailing. For instance, if it is just an image, with a caption, you may only want the image and the caption (not the heading bar, navigation bar, anything like that). For an article, you may want to send the entire text, or you may want to only send a snippet. I've found the simplest way to do this do make sure that actual content is in some
$content
like variable, which you can parse as you see fit.An e-mail template that you can inject the data from item #2 into. This may be a blank e-mail, an e-mail that is similar to your site, with your site's title, colors, etc, or something completely different. That's up to you.
An e-mailing script that can send the e-mail from item #3 to the e-mail from item #1, with the additional fact that the e-mail must be labeled as sent from the "sender's e-mail" from step #1. This would be accomplished with e-mail headers.
When you have all of these steps, it's relatively simple, acquire the necessary data from the form in item #1. Gather the required item data from step #2 given the identifier passed to the form in item #1. Load the e-mail template, and inject the data from items #1 and #2 into it, then construct the necessary headers comprised of the user details in item # 1. Then send this e-mail to item #4 for delivery.
You are asking a very broad question, and this is the best way that I can answer it without more details., I would suggest you look into each one of these item's individually, as it will help reduce your work load and give you a more flexible, extendable and robust script.