如何将文本框帖子作为可点击的超链接?

发布于 2024-11-24 08:11:38 字数 1015 浏览 1 评论 0原文

我正在处理一个表单,允许所有用户在输入文本框中输入网站网址,然后提交它(然后发布在后续页面上)。

我需要做什么才能让它回显 url 本身,如果单击将把任何人带到该网站?

下面是告诉它如何发布信息的代码:

// Let's find out if we have taxonomy information to display  
// Something to build our output in  
$taxo_text = "";  

// Variables to store each of our possible taxonomy lists  
// This one checks for a tool website 
$website_list = get_the_term_list( $post->ID, 'tool_website', '<strong>Tool Website:</strong> ', ', ', '' );
if ( '' != $website_list ) {  
$taxo_text .= "$website_list<br />\n";  
}  
// Output taxonomy information if there was any  
// NOTE: We won't even open a div if there's nothing to put inside it.  
if ( '' != $taxo_text ) {  
?>  
<div class="entry-utility">  
<?php  
echo $taxo_text;  
?>  
</div>  
<?

目前此代码的作用是(本质上)创建一个类别列表。因此,该网址将被发布,但当单击时,它会链接到一个页面,该页面显示该名称内“分类”的所有帖子。因此,如果输入“tools”作为 URL,它将有一个可点击的超链接,上面写着“tools”,点击后会重定向到一个新页面,该页面包含用字符串“tools”列出的所有提交的列表(

如果有意义的话)。 。

I have a form I am working on that allows all users to enter a website url in an input textbox and then submit it (being then posted on the subsequent page).

What would I need to do to have it echo the url itself that if clicked will take anyone to the website?

here is the code that tells it how to post the information:

// Let's find out if we have taxonomy information to display  
// Something to build our output in  
$taxo_text = "";  

// Variables to store each of our possible taxonomy lists  
// This one checks for a tool website 
$website_list = get_the_term_list( $post->ID, 'tool_website', '<strong>Tool Website:</strong> ', ', ', '' );
if ( '' != $website_list ) {  
$taxo_text .= "$website_list<br />\n";  
}  
// Output taxonomy information if there was any  
// NOTE: We won't even open a div if there's nothing to put inside it.  
if ( '' != $taxo_text ) {  
?>  
<div class="entry-utility">  
<?php  
echo $taxo_text;  
?>  
</div>  
<?

currently what this code does is make (essentially) a category listing. So the url will be posted, but when clicked it links to a page that shows all posts "categorized" within that name. So if one entered "tools" as the url, it would have a clickable hyperlink that says "tools" and when clicked would redirect to a new page that has a list of all submissions listed with the string "tools"

if that makes sense..

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

自由如风 2024-12-01 08:11:38

如果我理解你的问题,那么假设用户在名为“poster_url”的表单上的文本框中输入一个 URL,那么你需要输出一个带有该 URL 的链接,如下所示:

      <a href="<% echo $_POST['poster_url']%>">Poster's Website</a>

但是,由于直接输出类似的内容,可能应该首先进行一些验证用户进入后就被认为是不安全的。

If I understand your question then assuming that the user types a URL in a textbox on the form called "poster_url" you then need to output a link with that URL like this:

      <a href="<% echo $_POST['poster_url']%>">Poster's Website</a>

However, some validation should probably occur first since outputing something like this directly after a user enters it is considered unsafe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文