首页 / PHP / php-将错误添加到搜索表单
php-将错误添加到搜索表单
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了php-将错误添加到搜索表单,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1928字,纯文字阅读大概需要3分钟。
内容图文
我试图在搜索表单中添加错误,但是它不起作用,如果您想查看演示,可以继续进行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-将错误添加到搜索表单全部内容,希望文章能够帮你解决php-将错误添加到搜索表单所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。