douzi8112 2013-09-09 11:49
浏览 41
已采纳

从HTML文件中读取电子邮件地址并通过PHP文件向电子邮件地址发送电子邮件

I am trying to do something fairly simple, which is enable a visitor of a website to email themselves a copy of the list of phone numbers of the website.

On a HTML file a simple text book asks for the user to enter text (email):

 <b> Email Address:
   <input type="text" name="emailaddress"/>

So far I have the following code on a PHP file:

 <a href="mailto:emailaddress">Email me the list of Phone Numbers</a> 

However 'emailaddress' on the PHP file is not properly reading the input email address from the HTML page. When I change emailaddress on the PHP file to $emailaddress this ends up sending an email to '$emailaddress' instead of the input.

I would be extremely grateful for any help .

Andrew

  • 写回答

2条回答 默认 最新

  • dongren7374 2013-09-09 11:53
    关注

    You need to echo the $_POST-Variable instead of a string "emailaddress".

    <a href="mailto:<?php echo $_POST['emailaddress']; ?>">Email me the list of Phone Numbers</a> 
    

    i suggest that you send your input field via POST. By the way, you should check your POST-Var to be a valid email-address.

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

报告相同问题?