将登录表单数据发送到txt [英] Send login form data to txt

查看:91
本文介绍了将登录表单数据发送到txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试编写一个HTML登录表单,用于将登录数据发送到txt文件。

然而,它不起作用。单击登录按钮后没有任何迹象表明发生了任何事情(例如输入的信息没有消失),登录没有出现在我的txt文件中

这是我目前的代码有:

HTML:

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:


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>





另外,我看了,我找不到任何深度足以描述这个的东西我:

我可以这样做,以便在提交时输入txt文件上的登录数据,弹出窗口也有一个文本框(提交时)将值添加到a不同的txt文件?谢谢!



我尝试了什么:



我试过了确保action的名称=与php文件的名称相匹配,并没有真正改变任何东西。我做错了什么?



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?

推荐答案

_POST ['Login']){
_POST['Login']){


myFile =data.txt;
myFile = "data.txt";


fh = fopen(
fh = fopen(


这篇关于将登录表单数据发送到txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆