TheJoey Posted August 28, 2009 Share Posted August 28, 2009 Placing information in a Seperate Directory for each register user. file_put_contents('../logins/'.$username.'_type_username.txt', 'Done'); file_put_contents('../logins/'.$password.'_type_password.txt', 'Done'); file_put_contents('../logins/'.$name.'_type_profilename.txt', 'Done'); file_put_contents('../logins/'.$email.'_type_profileemail.txt', 'Done'); So if user Me registers a folder me will be created thanks in advance Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 This is a dangerous way to collect user information, Why are you doing that , especially each user having 4 files for such little information? You're not even asking a question, what is it you want us to help you with? If you're wanting to create a new folder.. file_put_contents('../logins/'.$username.'/'.$username.'_type_username.txt', 'Done'); Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 well it makes it easier for me to proccess. At the moment its placing 4 files in logins folder. is there a way to make it so when "me" registers a folder in logins called "ME" is where the information is stored. Is there a way of putting all that info into one file. When i tried it messed up all my code because it was reading it wrongly. Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 well it makes it easier for me to proccess. At the moment its placing 4 files in logins folder. is there a way to make it so when "me" registers a folder in logins called "ME" is where the information is stored. Is there a way of putting all that info into one file. When i tried it messed up all my code because it was reading it wrongly. Use fread and fwrite instead of file_put_contents first of all to be able to write to the same file.. and use my code above to create a new folder per user.. It's basic but you get how it's done, just with the slashes. Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 Warning: file_put_contents(../logins/Joe/Joe_type_username.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 14 Warning: file_put_contents(../logins/Joe/joe_type_password.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 15 Warning: file_put_contents(../logins/Joe/joe_type_name.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 16 Warning: file_put_contents(../logins/Joe/joe_type_email.txt) [function.file-put-contents]: failed to open stream: No such file or directory in C:\xampplite\htdocs\Trial\Login\register\reg.php on line 17 file_put_contents('../logins/'.$username.'/'.$username.'_type_username.txt', 'Done'); file_put_contents('../logins/'.$username.'/'.$password.'_type_password.txt', 'Done'); file_put_contents('../logins/'.$username.'/'.$name.'_type_name.txt', 'Done'); file_put_contents('../logins/'.$username.'/'.$email.'_type_email.txt', 'Done'); im working on putting into fwrite its just i find fwrite hard to work with due to recalling it Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 You need to set your permissions for folders to be written to, such as 777.. but this just shows you how unsecure your method is. Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 im using windows and apache. How would i do so on this? Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 I'd recommend using an SQL database to store files.. if you're wanting to put data into a flatfile then follow a tutorial like this with fread/write.. http://www.xentrik.net/php/flatfile.php Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 its only for personal preferences. Theres no need for secruity. So there is no way to set permissions for windows? xammp Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 When i try saving the files via fwrite it saves in a messy format. like Name,age,email,password then repeats on the same line even after /n Quote Link to comment Share on other sites More sharing options...
oni-kun Posted August 28, 2009 Share Posted August 28, 2009 Make your WWW folder read/write/execute in properties if available, and you'd use something such as mkdir to create a folder.. such as.. mkdir("../logins/$username/"); file_put_contents('../logins/'.$username.'/'.$username.'_type_username.txt', 'Done'); That might work.. like Name,age,email,password then repeats on the same line even after /n You should type \n, not /n if that was your mistake Quote Link to comment Share on other sites More sharing options...
TheJoey Posted August 28, 2009 Author Share Posted August 28, 2009 fwrite($fp, $email."||".$fname."||".$lname."||".$age."||".$address."||".$city."\n"); that was my code when viewed in notepad it was on same line in wordpad in was viewed per line but when i do <?php readfile("text.txt"); ?> it views the same notepad 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.