我有一个数据库,当查询与我们数据库中的任何内容都不匹配时,我正在尝试将我的电子邮件地址显示为超链接。我正在使用以下内容......
PHP代码......
else{ // if there is no matching rows do following
echo "<br /><br /><br /><strong><h2>"."You have searched a term that is not in the database. Please contact <a href=\"mailto:email@domain.com" . htmlentities($_POST['email@domain.com']) . "\">".htmlentities($_POST['email@domain.com']) . "</a>, if you think this term should be added."."</h2></strong>";
但是,结果我看起来像这样......
“您搜索了数据库中没有的字词。如果您认为应添加该字词,请与我们联系。”
除了超链接的电子邮件地址外,其他所有内容都有。
思考?
答案 0 :(得分:2)
<a href="mailto:<?php echo $_POST['email_field_name']; ?>">
<?php echo $_POST['email_field_name']; ?>
</a>
虽然,您可能希望提供一些电子邮件地址混淆机制。这将为您的用户免受垃圾邮件机器人挖掘您的电子邮件地址提供一定程度的保护。通常,不受保护的地址(如上例所示)将随着时间的推移收到越来越多的垃圾邮件。
如果您正在显示它们的页面是在登录后面保护的,那么这不是一个问题。
答案 1 :(得分:1)
试试这个..
else{ // if there is no matching rows do following
$mail = htmlentities('email@domain.com');
echo "<br /><br /><br /><strong><h2>" .
"You have searched a term that is not in the database. Please contact <a href=\"mailto:$mail\">$mail</a>, if you think this term should be added.</h2></strong>";
答案 2 :(得分:0)
$_POST['email@domain.com']
可能未定义(或为空)。
你不只是想要:"email@domain.com"
?
答案 3 :(得分:0)
此:
$_POST['email@domain.com']
应改为:
$_POST['email'];
其中,电子邮件是您的表单字段。仅当您从上一页获取电子邮件地址的值作为表单字段时,此方法才有效。如果不是这样,那么只需用“email@domain.com”替换$ _POST ['email@domain.com'];
答案 4 :(得分:0)
$_POST['email@domain.com']
应为$_POST['email']
。在email@domain.com
之后不应该mailto
。你的陈述应该是这样的:
echo "<br /><br /><br /><strong><h2>"."You have searched a term that is not in the database. Please contact <a href='mailto:" . htmlentities($_POST['email']) . "'>".htmlentities($_POST['email']) . "</a>, if you think this term should be added."."</h2></strong>";