Problem Displaying Contents of File
Posted: Thu Jun 28, 2007 2:29 am
I have a file which lets you make a name and a password in a text file, and what does work is that when you click the form its action is the following script and adds the name and password to the file. Now, the problem is that when I try to display the contents of $members[0] or $name[$i][0] or any other variable that I got from the file, instead it displays something like Resource id #1. How can I fix this? If you have any questions, feel free to ask.
Code: Select all
<?php
$filename = "members.txt";
$newmember = "";
$memberfile = fopen($filename, "r+");
$members = explode("||", $memberfile);
fclose($memberfile);
echo $members[0];
for ($i=0;$i<100;$i++) {
$names[$i] = explode("^^", $members[$i]);
}
for ($i=0;$i<100;$i++) {
if ($_POST["name"] == $names[$i][0]) {
$already = 1;
}
}
if ($_POST["name"] != "" && $_POST["pass"] && $already != 1) {
$newmember = $_POST["name"]."^^".$_POST["pass"]."||";
$file = fopen("members.txt", "a+");
fputs($file,$newmember);
fclose($file);
echo "Your account has been successfully made.<br />";
}
else {
echo "Your account has failed to be made. Please try again.<br />";
}
for ($i=0;$i<100;$i++) {
echo "Name:".$names[$i][0]."<br />";
echo "Password:".$names[$i][1]."<br /><br />";
}
?>