gpt4 book ai didi

php - 向搜索表单添加错误

转载 作者:可可西里 更新时间:2023-11-01 01:14:17 26 4
gpt4 key购买 nike

我尝试在搜索表单中添加一个错误,但它不起作用,如果你想看演示,你可以继续 Svapomc.com ,请有人可以帮助我吗?非常感谢

    </html>
<head>
<link href="cerca.css" rel="stylesheet" type="text/css"/>
</head>

<body>
<form action="" method="get">

<input type="text" name="search" placeholder="Cerca la mappa da scaricare (può essere pure incompleto)"/>
<input type="submit" value="Cerca"/>

</form>
<body>

</html>

<?php
//--- get all the directories
$search = $_GET["search"];
$dirname = 'maps';
$findme = "*.bz2";
$dirs = glob($dirname.'*', GLOB_ONLYDIR);
$files = array();
//--- search through each folder for the file
//--- append results to $files
foreach( $dirs as $d ) {
$f = glob( $d .'/'. $findme );
if( count( $f ) ) {
$files = array_merge( $files, $f );
}
}
if( count($files) ) {
foreach( $files as $f ) {
if(strpos($f, $search) !== false and strpos($f, '.nav') === false and strpos($f, '.jpg') === false and strpos($f, '.txt') === false and strpos($f, '.jpe') === false or !isset($_GET["search"]) or $search == ""){
$f1 = str_replace('maps/', '', $f);
$f1 = str_replace('.bz2', '', $f1);
$f1 = str_replace('.bsp', '', $f1);
echo "<div class='ciao'><p>{$f1} <a download href='{$f}'>Download</a></p></div><br>";
}
}
} else {
echo "<p>Error message here</p>";
}
?>

这是我认为问题出在其他代码但我不知道的所有代码

最佳答案

也许你有文件,但没有匹配......

$file_found = false;
if( count($files) ) {
foreach( $files as $f ) {
if(strpos($f, $search) !== false and strpos($f, '.nav') === false and strpos($f, '.jpg') === false and strpos($f, '.txt') === false and strpos($f, '.jpe') === false or !isset($_GET["search"]) or $search == ""){
$f1 = str_replace('maps/', '', $f);
$f1 = str_replace('.bz2', '', $f1);
$f1 = str_replace('.bsp', '', $f1);
echo "<div class='ciao'><p>{$f1} <a download href='{$f}'>Download</a></p></div><br>";
$file_found = true;
}
}
}

if(!$file_found){
echo "<p>Non è stata trovata nessuna mappa con questo nome</p>";
echo '<img src="yourimagehere.jpg"/>';
}

关于php - 向搜索表单添加错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43843510/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com