Immortal1380 Posted January 8, 2013 Share Posted January 8, 2013 I hate to ask for help for my first, but I am currently having issues writing out a code for a program in progress. Basically, I am not great at php, but I need a code that will store information when sent to it from the program itself. I am setting it up to store login information, so the program writes out (lets say the username), when the person clicks the 'Next' button, it sends it to the .php and the .php will write that certain file out with the username as the .txt file name. I have this so far, if someone could figure out the code, that would be amazing. Thanks! <?php $msg = $_GET['w']; $logfile= (['username.txt'); $fp = fopen($logfile, "a"); fwrite($fp, $msg); fclose($fp); ?> Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 8, 2013 Share Posted January 8, 2013 We could help but this is entirely the wrong way to store login information. Are you just trying to learn about writing to files, or actually make something people log into? Quote Link to comment Share on other sites More sharing options...
Immortal1380 Posted January 8, 2013 Author Share Posted January 8, 2013 It will not be used for anything public since I am not well experienced at this, so it would be more for learning purposes. Quote Link to comment Share on other sites More sharing options...
codefossa Posted January 8, 2013 Share Posted January 8, 2013 What OS is your server running on? If you must go flatfile, personally I use grep (unix) with exec to check the login. You really should stick to SQL, but anyways ... Let me know your OS and I'll help a little. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 8, 2013 Share Posted January 8, 2013 If your form is using get as the method, replace 'username' with $_GET['username'] etc. If it uses post, use POST.  Quote Link to comment Share on other sites More sharing options...
Immortal1380 Posted January 8, 2013 Author Share Posted January 8, 2013 Trying to store on a webserver, i personally have windows 7 but the server I have no clue, the host is http://square7.ch/ Quote Link to comment Share on other sites More sharing options...
codefossa Posted January 8, 2013 Share Posted January 8, 2013 On any webpage, throw this at the top (a PHP page of course). <?php die(exec("uname -a")); ?> Â It will say. Probably Linux .. but pointless to go on if not. You can use PHP to go through the file, but it's not as fast. Quote Link to comment Share on other sites More sharing options...
Immortal1380 Posted January 8, 2013 Author Share Posted January 8, 2013 If you need more information, the program that I am writing is more of a registration form, not a login one. It is to write the .txt files onto the webserver for the login form to and check if they are correct, if they are, the program then continues on to the next form Quote Link to comment Share on other sites More sharing options...
codefossa Posted January 8, 2013 Share Posted January 8, 2013 Well I assume you want to be able to use them for logging in as well, and you don't want a ton of files for each login. You can put it all into one, then grep through the file to see if the login + pass exists for logging in. For registration, you would make sure the name doesn't exist, then append it to the file. Quote Link to comment Share on other sites More sharing options...
Immortal1380 Posted January 8, 2013 Author Share Posted January 8, 2013 Yes, that is what I was looking for, but if it would be easier I have no problems storing a ton of text files in the directory for each login information. Quote Link to comment Share on other sites More sharing options...
codefossa Posted January 8, 2013 Share Posted January 8, 2013 It's not any easier. It's just easier to know what you have to work with before you make it. Check the post I put above with the line of PHP and let me know what it returns. Quote Link to comment Share on other sites More sharing options...
Immortal1380 Posted January 8, 2013 Author Share Posted January 8, 2013 Returns that exec is disabled for security reasons, I MIGHT look into some mySQL stuff and see how that goes for database storage instead. Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 8, 2013 Share Posted January 8, 2013 Use MySQL. Quote Link to comment Share on other sites More sharing options...
Immortal1380 Posted January 8, 2013 Author Share Posted January 8, 2013 Use MySQL. Alright, will do, thanks! 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.