Textfield结果成为超链接

时间:2012-11-09 11:04:34

标签: php html hyperlink textfield

我写了这个表格,你写下姓名,姓名,电话和电子邮件。 使用HTML和PHP。

name: "textfield here"
lastname: "textfield here"
phone: "textfield here"
email: "textfield here"

我的PHP代码:

 echo "<H1>Hello " .$_POST['name']. " " .$_POST['surname']; 

 echo "I'm calling you at " .$_POST['telephone']. " or email you at ".$_POST['email']; 

如何将email的结果作为超链接发布?

4 个答案:

答案 0 :(得分:2)

要创建链接,请使用<a>标记,对于电子邮件链接,您可以将href设置为mailto:xyz

Mailto reference

还考虑研究XSS,因为您的代码容易受到攻击。请注意htmlentities()下面的用法以防止XSS。

echo "<h1>Hello " .htmlentities($_POST['name']). " " .htmlentities($_POST['surname']) . "</h1>"; 

echo "<p>I'm calling you at " .htmlentities($_POST['telephone']). " or email you at <a href=\"mailto:" . htmlentities($_POST['email']) . "\">".htmlentities($_POST['email']) . "</a></p>"; 

答案 1 :(得分:0)

echo "I'm calling you at " .$_POST['telephone']. " or email you at <a href=\"mailto:{$_POST['email']}\">{$_POST['email']}</a>";

答案 2 :(得分:0)

一个mailto?

根本不是我喜欢它(你会发现很难找到任何人)......

echo "I'm calling you at " .$_POST['telephone']. " or email you at <a href='mailto:".$_POST['email']."'>".$_POST['email']."</a>";

答案 3 :(得分:0)

使用这个:

    echo "I'm calling you at " .$_POST['telephone']. " or email you at 
    <a href=\"mailto:".$_POST['email'].">" $_POST['email']."</a>";