Basically i have the search script working well, but i need to replace the $input with $inputused if word is found.
I have tried str_replace() with no luck any ideas?
Thank you

<html>
<body>
<form name="form" method="post">

<br><input type="text" id="search" name="search_box" style="background:#000006; color: #FF0000" />


                   <br><input type="submit" name="submit" value="Search for Key" />

            </form>


    </body>
</html>





<?php
$myurl = "./testFile.txt";
$input = $_POST['search_box'];
$inputused = $input . "-" . "USED";

if(isset($_POST['submit'])){
if (!strlen(trim($_POST['search_box']))){
echo "You must enter a key.";
} else {

if(isset($_POST['submit'])){
$file = file_get_contents($myurl);
$split = explode("\n", $file);

if(in_array($input, $split))
{
    echo "It's here!";
} else
{
echo "NOT FOUND";
}
}
}
}
?>

I got it. seems to works okay but if theres a better way you know of..

<html>
<body>
<form name="form" method="post">

<br><input type="text" id="search" name="search_box" style="background:#000006; color: #FF0000" />


                   <br><input type="submit" name="submit" value="Search for Key" />

            </form>


    </body>
</html>





<?php
$myurl = "testFile.txt";
$input = $_POST['search_box'];
$inputused = $input . "-" . "USED";
$lines = file($myurl);
$cookie_file_path=$myurl;


if(isset($_POST['submit'])){
if (!strlen(trim($_POST['search_box']))){
echo "You must enter a key.";
} else {

if(isset($_POST['submit'])){
$file = file_get_contents($myurl);
$split = explode("\n", $file);

if(in_array($input, $split))
{
    echo "It's here!";
$contents = file_get_contents($cookie_file_path);
file_put_contents($cookie_file_path, str_replace($input, $inputused, $contents));
} else
{
echo "NOT FOUND";
}
}
}
}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.