I'm trying to write username and password to a new line in a txt file. The output should be something like this in the txt file. I know this is not very secure but its just for learning purposes
Sebastian password John hfsjaijn
This is what i have so far
if(isset($_GET['register'])) // { $user = $_GET['username']; $password=$_GET['password']; $fh = fopen("file.txt","a+"); fwrite($fh,$user."\n"); //write to txtfile fwrite($fh,$password."\n"); // write to txtfile fclose($fh); }
EDIT: Here's the solution
if(isset($_POST['register'])) // { $user = $_POST['username']; $password=$_POST['password'].PHP_EOL; $fh = fopen("file.txt","a+"); fwrite($fh,$user." ".$password); //write to txtfile fclose($fh); } ?>