So In my php code Im trying to have this code check my text file to see it a string exists. But every time I put the code in whether the string exist or not it echos the code for if the string exists.
$addemail = $_POST["subemail"];
$searchfile = file_get_contents("emailist.txt");
if (!strpos($searchfile, "$addemail"))
{
echo "Your email is already in our database.";
}
else
{
code to be executed if string doesn't exist.
}
Thanks in advance this really has me stumped :\
What your current code does is say “Your email is already in our database.” in the event that the email is not in the database, or if it’s the first email (you should always use the === or !== comparison with strpos). The code should be: