表单提交登录页:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>登录页面</title>
<!--havcom图标引入-->
<link rel="shortcut icon" href="网页图标.ico">
<link href="css/login.css" rel="stylesheet" type="text/css">
<style>
body {
background-image: url("images/666.jpg");
background-repeat: no-repeat;
background-size:100% 100%;
background-attachment:fixed;
}
</style>
</head>
<body>
<div class="login">
<div class="login-concent">Login</div>
<div class="user">
<form name="login" action="index.php" method="post">
<input type="text" name="user" size="30" required autofocus placeholder="2-16位用户" pattern="^[\u4e00-\u9fa5a-zA-Z0-9_-]{2,16}$" class="input-item">
<input type="password" name="password" size="30" required placeholder="不少于6位密码" pattern="^[\w!@#$%^&*?-]{6,}$" class="input-item">
<input type="submit" value="登录" class="log-but">
</form>
</div>
</div>
</body>
</html>
表单信息保存text页面代码:index.php
<?php
$user=trim($_POST['user']);
$password=trim($_POST['password']);
if(!$user || !$password){
echo 'please make sure no empty input';
exit;
}
//write to test.txt
$handle=fopen('test.txt','a+');//打开该文件,以读写的方式
fwrite($handle,'$user:'.$user.'-----'.'$password:'.$password."\r\n");//在打开的文件中写入内容
fclose($handle);//关闭数据流
?>