php - 如何获取文本输入并将其粘贴到使用 PHP 的链接前面?
问题描述
我目前正忙于(重新)制作荷兰语维基百科网站。我想制作搜索栏。我的想法是获取文本输入,当您单击搜索时,文本将转到链接的前面,如下所示:
这是当前的搜索栏:
<div align='center'>
<form method="submit" action='php/zoeken.php'>
<input placeholder="zoeken"id="zoeken"class='zoeken'type="text">
<button class='button'type="submit">zoeken</button>
</div>
解决方案
<form action="THE PAGE YOU SENT REQUEST" method="POST">
<input placeholder="zoeken" name="zoaken" type="text">
<input type="submit" value="Submit">
</form>
<?php
/* Get the text input with $_POST */
$string = $_POST['zoaken'];
/* Redirect the page to the new address */
header('Location: https://nl.wikipedia.org/wiki/'.$string);
您还应该检查文本是否为空、空或有漏洞。
推荐阅读
- javascript - 如何动态获取执行另一个函数的函数名?
- javascript - onsubmit 问题不允许发送操作
- weblogic - 通过 WLST 的 Weblogic 部署健康状态
- flutter - 如何调整 DropdownButton 上的箭头/插入符号?
- c++ - C++重载<<操作只打印LinkedList的内存地址
- docker - 获取 https://registry-1.docker.io/v2/:net/http: 等待连接时取消请求(等待标头时超出 Client.Timeout)
- reactjs - 如果我在 React (Typescript) 中从父类扩展子类,为什么父类中的状态是只读的?
- javascript - 在 React 和 Redux 中删除页面/路由后重定向
- phpmyadmin - 禁止访问 phpmyadmin
- c - C中的bsearch函数和结构