<?php
error_reporting(0);
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
if(isset($_POST['submit']))
{
$searchterm = $_POST['searchterm'];
//$dir = scandir("../frPHP");
if($searchterm !== " ")
{
echo "Is empty!!";
}
else
{
$txt = 'Hallo Ik ben een Hallo-persoon!!';
//$preg = '/foo|bal/';
$preg = '/[$searchterm]/';
$dir = "../frPHP";
if(preg_match($preg, glob($dir), $matches))
{
foreach ($matches as $filename)
{
echo "Founded results:<br>";
echo "<b><div class='red'>".$matches[0]."</div></b>";
echo ' inside: '.$txt;
}
}
else
{
echo "No match!!";
}
}
}
?>
<html>
<head>
<style>
@import url('www.googleapis/fonts/');
.red
{
color: red;
display: inline-block;
}
</style>
</head>
<body>
<form action="index.php" method="POST">
<input type="text" name="searchterm" placeholder="Your searchterm"/>
<input type="submit" name="submit" value="Search"/>
<input type="reset" name="reset" value="Reset"/>
</form>
</body>
</html>