Only Once...
Moderator: General Moderators
Only Once...
I am wondering how I can check to see if someone's name is already in the file, and if so, not re-enter their name. If it isn't, I want it to enter the name. Currently it enters the name repeatedly upon reloading. Surely there is a way to search the text file and do this...
Usernames.txt
Code
Code: Select all
John,Stephen,Mac,Takuma,PepCode: Select all
<?php
$fh = fopen("usernames.txt","r");
$content = fread($fh,filesize($fh));
$content = explode(",",$content);
for($i = 0; $i <= count($content); $i++) {
if($contentї$i] == $_POSTї"username"]) {
//Username already exists
} else {
//Username do not exist in the file
}
}
fclose($fh);
?>