TheJoey Posted August 27, 2009 Share Posted August 27, 2009 i have a question. i have stored all my information for a user via FWRITE is there a way to retrive this information when needed. Quote Link to comment Share on other sites More sharing options...
McAwesome Posted August 27, 2009 Share Posted August 27, 2009 check out fgets(), and fopen() http://us3.php.net/manual/en/function.fgets.php? Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 27, 2009 Author Share Posted August 27, 2009 i had a read of them, but cant find a way to use them both together. I might be able to write to single scripts Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 27, 2009 Author Share Posted August 27, 2009 i have had a read, i just dont c how i can implement my code with fwrite to allow for a login. <?php error_reporting(E_ALL); ini_set('display_errors', '1'); if (isset($_POST['email'] , $_POST['fname'] , $_POST['lname'] , $_POST['age'] , $_POST['address'] , $_POST['city'])) { // some form of email validation $email = ($_POST['email']); $fname = ($_POST['fname']); $lname = ($_POST['lname']); $age = ($_POST['age']); $address = ($_POST['address']); $city = ($_POST['city']); $user_info = $email . "||" . $fname . "||" . $lname . "||" . $age . "||" . $address . "||" . $city; // write-to file $filename = 'text.txt'; // attempt to open the file if ($handle = fopen($filename, 'a')) { // attempt to write to the file if (!fwrite ($handle, $user_info)) { echo 'Cannot write to file'; } else { echo 'Written to file'; } } fclose($handle); } ?> Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 27, 2009 Author Share Posted August 27, 2009 does anyone have a bit of code where i can work from. Quote Link to comment Share on other sites More sharing options...
gaza165 Posted August 27, 2009 Share Posted August 27, 2009 Why are you using a text file to store login information, wouldn't it be best to use a database instead?? Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 correct its just something i want to try do. Is it possible? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 correct its just something i want to try do. Is it possible? First look at this web page here, I was wanting to do the same thing and I was able to. http://www.xentrik.net/php/flatfile.php I wrote functions to read/write the page, it very successfully appends and reads the users as arrays, with any extra data as needed. Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 well my code is pretty similar to that just have to add explode functions and a few others. Once i serperate the info how i create a login? Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 $user_info = $email . "||" . $fname . "||" . $lname . "||" . $age . "||" . $address . "||" . $city . "\n" ; i want to print it on a seperate line but it doesnt seem to do it Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 $user_info = $email . "||" . $fname . "||" . $lname . "||" . $age . "||" . $address . "||" . $city . "\n" ; i want to print it on a seperate line but it doesnt seem to do it Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.