0
error find string from input field
<form method="POST"> <input type="text" name="search"> <input type="submit" value="Search"> </form> <?php if ($_SERVER['REQUEST_METHOD'] === 'POST') { $search = $_POST['search']; $lines = file('data.txt'); } foreach($lines as $line) if(strpos($line, $search) !== false){ echo $line; } ?>
1 Antwort
0
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$search = $_POST['search'];
$lines = file('data.txt');
foreach($lines as $line) {
if(strpos($line, $search) !== false){
echo $line;
}
}
}
I think that "foreach" is not correctly placed within the "if" statement. Try that code I give you with "foreach" inside "if"