I am trying to save requested string to a text file. If string exist in file, it returns message if not it saves string and return ok message. Below is what I did and its not working. I do not get any file in the current directory.
<?php
$data=$_REQUEST["data"];
function registration($dat)
{
$file = 'data.txt';
if( strpos(file_get_contents($file),$_GET[$dat]) !== false) {
$current = file_get_contents($file);
$current .= $dat;
file_put_contents($file, $current);
$result.='Data Added ok!!';
return $result;
} else {
$result.='Data Already Saved';
return $result;
}
}
echo registration($data);
?>