saving variables with fopen (PHP)

thezone1

New Member
Messages
192
Reaction score
0
Points
0
Hi i wanted to ask if anyone knows how to save variables to a text file heres the code im using

$fh = fopen("$uid/list.php", "w+");
if($fh==false)
die("unable to create file");


if($fh)
{
if(!fwrite($fh, "<?

session_start();
if (!isset(\$_SESSION['uid'])) {
\$_SESSION['uid'] = \$_REQUEST['uid'];
\$_SESSION['pwd'] = \$_REQUEST['pwd'];

}
\$uid = \$_SESSION['uid'];
\$pwd = \$_SESSION['pwd'];


\$res = mysql_query(\"SELECT * FROM users WHERE uid='\$uid' AND pwd='\$pwd' and status='active'\");
\$re = mysql_fetch_array(\$res);
if(mysql_num_rows(\$res) != 0) {

if (\$uid == '$uid **** I WANT A VARIABLE VALUE TO ECHO HERE ****') {
// Define the full path to folder from root
\$path = \"users/administrator/docs/\";
// Open the folder
\$dir_handle = @opendir(\$path) or die(\"Unable to open \$path\");
// Loop through the files
while (\$file = readdir(\$dir_handle)) {
if(\$file == \".\" || \$file == \"..\" || \$file == \"list.php\" )
continue;
\$a = \$file;
\$b = \"<a href=users/$uid ** HERE AS WELL **/docs/\";
\$c = \">\$file</a><br>\";
echo \$b ;
echo \$a ;
echo \$c ;
}
// Close
closedir($dir_handle);
}
;} else { echo \"<p>YOU DO NOT HAVE ACCESS TO THIS DIRECTORY, PLEASE LOG IN!</p>\" ;}

?>
"))
die("couldn't write to file.");

}


any help welcome thanks
 
Top