I am new to php and am trying to setup a script that will
allow people to register to a plain text file in this format user:password.
So far I have gotten the file to write the data but I would like
for the script to compare the data already in the file with the
data a user is trying to write to that file so that if the data they
are trying to write already exist it will tell them so and not write
the data again.
Code: Select all
<?php
$name = "";
$password = "";
$fp = fopen("registered","a");
$fp = fopen("registered","a");
if(!$fp) {
print "error! please contact the webmaster.";
exit;
}
$stringtowrite=$name.":".$password;
fwrite($fp, $stringtowrite."\n".$stringtowrite2);
fclose($fp);
?>
<?php
echo "Username: $name Password: $password wrote to file";
?>