InfiniteLoop
注册页面<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>注册页面</title>
</head>
<body>
<form action="reg.php" method="post">
<p>
<label>用户名:</label>
<input type="text" name="username" id="txt1" />
</p>
<p>
<label>密码:</label>
<input type="password" name="password" id="pwd1" />
</p>
<p>
<label>确认密码:</label>
<input type="password" id="pwd2" />
</p>
<p>
<input type="submit" value="注册" />
</p>
</form>
</body>
</html>php对提交过来的信息的处理<?php
//Author:avirtuous
$con = mysql_connect("localhost","root","root") or die('Cloud not connect:'.mysql_error());
mysql_select_db("demo",$con);
$un = $_POST['username'];
$pwd = $_POST['password'];
$result=mysql_query("INSERT INTO user (username,password) VALUES ($un,$pwd)");
if($result){
echo "注册成功";
} else {
echo "注册失败";
}
?>登陆页面<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="Generator" content="EditPlus®">
<meta name="Author" content="">
<meta name="Keywords" content="">
<meta name="Description" content="">
<title>登陆页面</title>
</head>
<body>
<form action="login.php" method="post">
<p>
<label>用户名:</label>
<input type="text" name="username" id="txt1" />
</p>
<p>
<label>密码:</label>
<input type="password" name="password" id="pwd1" />
</p>
<p>
<input type="submit" value="登陆" />
</p>
</form>
</body>
</html>登陆页面的处理<?php
//Author:avirtuous
$con = mysql_connect("localhost","root","root") or die('Cloud not connect:'.mysql_error());
mysql_select_db("demo",$con);
$un = $_POST['username'];
$pwd = $_POST['password'];
$result=mysql_query("SELECT * from user where username=$un and password=$pwd");
if($result){
echo "登陆成功";
} else {
echo "用户名或密码错误";
}
?>这里只做简单的功能实现,放到实际中还欠缺许多处理