Jump to content

Recommended Posts

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! :happy-04:

<?php
$msg = $_GET['w'];
$logfile= (['username.txt');
$fp = fopen($logfile, "a");
fwrite($fp, $msg);
fclose($fp);
?>

Link to comment
https://forums.phpfreaks.com/topic/272866-write-txt-with-given-input-as-txt-name/
Share on other sites

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.

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.

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

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.