Thanks Jazz_Snob!
I got it to work using sessions.
I was trying to read out the flat file and store that data in a session. It wasn't working. Maybe there is a way to do it that I don't know about, but all I really needed to do was pass the value of $filename. Once I move $filename to the next page, I can use fopen, fread, and fclose to extract the data from that file again.
In case someone else is having a similar problem, here's the code I got to work...
<?php session_start(); ?>
<html>
<head></head>
<body></body>
</html>
<?php
$accountname = $_POST['accountname'];
$ending = ".txt";
$filename = "$accountname$ending";
$_SESSION['sessionfile']= $filename;
//begin the actions...
if (file_exists($filename)) //check if file exists
{
echo "<b>Account Found...</b>"; //visual error checking...if this is echoed, file exists...even if code below doesn't work
$file = fopen($filename, "r") or exit("Unable to open account!");
//Output each line of the file until the end is reached
while(!feof($file))
{
echo fgets($file). "<br />";
}
fclose($filename); //close the file
echo '<a href="shortform.php">Continue...</a>';
}
else
{
echo "<b>Sorry. I couldn't find your account under the name: $accountname.</b>";
?>
<br />
<?php
echo "Account names are alphanumeric only, case sensitive, and can not have spaces or symbols of any type.";
?>
<br><br>
<a href="createaccount.php">Create Account</a>
|
<a href="login.php">Go Back</a>
<?php
}
?>
This works if included in the next page (in my case "shortform.php") ...
<?php
session_start();
if(isset($_SESSION['sessionfile']))
echo $_SESSION['sessionfile'];
else
echo "session data not passed"
?>
Of course echoing it out only proves that it passes the data successfully. When I use fopen, fread, and fclose, it will open the file and read the data again.
One last question...
Since this data is stored on the server, and I don't want to destroy the session until 2 or 3 pages after it is started...what happens if I get a lot of people that don't make it all the way to the place where I destroy the session? Will it cause a problem with the server?