日期:2014-05-17  浏览次数:20456 次

PHP URL問題
各位大大 小弟是新手,不好意思 這邊有個很基礎的問題想請教一下><

如何讓PHP表單頁面(post.php)輸入一串URL, 送出URL後到另一個頁面(index.php),並在index.php中顯示在post.php中輸入的URL並將此URL變成超連結,請問要怎麼做呢? 謝謝!


//post.php的code:

<html>
<head></head>
<body>
<form action="index.php" method="post">
輸入大名:<input type="text" name="UrName"><br>
輸入網址超連結位置:<input name="myurl"><br>
<input type="submit" name="btnSubmit" value="送出">
<input type="Reset" name="btnReset" value="清除">
</form>
</body>
</html>


=============================我是分隔線================================

//index.php的code

<html>
<head></head>
<body>
<?php
$ID=$_POST['UrName'];
$Url=$_POST['myurl'];
echo "您的大名: $ID<br>";
echo "網址:$url<br>";
//以上網址列出並可顯示出URL的超連結,方便使用者點選
?>
</body>
</html>

------解决方案--------------------
HTML超链接的话 echo "网址: <a href=\"{$url}\" title=\"This is the link\">{$url}</a>";
输出结果就像这样 网址:http://xxx.com
------解决方案--------------------
#1正解
echo "网址: <a href='{$url}'>{$url}</a>";