我有一个搜索栏,当用户输入一个单词时,会显示包含该单词的文件名。为了更清楚地解释这一点,我将添加我目前正在处理的代码。
HTML
这个程序工作得很完美,除了它是区分大小写的,而且如果有额外的空格也会出错。例如,如果我搜索"hello",文件名是"Hello"或"hello "时,搜索就无法正常工作。有没有人知道如何使其忽略大小写和空格?谢谢。
HTML
<form method="post" action="submit.php">
<input name="search" type="text" value="">
<button type="submit" name="Submit">
Submit</button>
</form>
submit.php
if (isset($_POST['search'])){
header( 'Location: http://headerLocation/'.$_POST['search'].'.xml' ) ;}
else {
echo "Warning, your request could not be completed";
}
?>
这个程序工作得很完美,除了它是区分大小写的,而且如果有额外的空格也会出错。例如,如果我搜索"hello",文件名是"Hello"或"hello "时,搜索就无法正常工作。有没有人知道如何使其忽略大小写和空格?谢谢。
$_POST['search']
转换为小写字母。 - samayo