一个简单的注册登录模块
2011-06-13 15:27
549 查看
创建数据库:
create database db;
use db;
create table users (SERIAL int(11) not null primary key auto_increment,ID varchar(20) not null,passwd varchar(20) not null)
会员注册页面 add.php:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charest=GB2312"/>
<title>会员注册</title>
</head>
<body>
<h1 align="center">会员注册</h1>
<form name="form1" action="add_chk.php" method="post">
<p align="center">请输入你要使用的帐号:<input type="text" name="ID"/></p>
<p align="center">请输入你要使用的密码:<input type="password" name="passwd"/></p>
<p align="center">请重新输入密码以确认:<input type="password" name="repasswd"/></p>
<p align="center"><input type="submit" name="提交"/><input type="reset" name="重置"/></p>
</form>
</body>
</html>
注册信息校验页面 add_chk.php:
<?php
$id=$_POST['ID'];
$passwd=$_POST['passwd'];
$repasswd=$_POST['repasswd'];
if($id==null || $passwd==null || $repasswd==NULL)
{ echo "帐号或密码为空,返回重新输入";
}
if ($_POST['passwd']!=$_POST['repasswd'])
{
echo"两次密码不符";
}
$link=mysql_connect("localhost","root","123456");
mysql_select_db("db",$link);
$sqlstr="insert into `users`(SERIAL,ID,passwd) values('','".$_POST['ID']."','".$_POST['passwd']."')";
$result=mysql_query($sqlstr,$link);
echo "注册成功";
mysql_close($link);
?>
登录页面login.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>会员登录</title>
</head>
<body link="blue" vlink="purple" alink="red">
<h1>会员登录</h1>
<form name="form2" action="chk.php" method="post">
<p align="center">帐号:<input type="text" name="ID"/></p>
<p align="center">密码:<input type="password" name="passwd"/></p>
<p align="center"><input type="submit" name="提交" value="提交"/><input type="reset" name="重置"/>
<h3 align="center"><a href="add.php">注册</a></h3>
</form>
</body>
</html>
登录验证chk.php:
<?php
$link=mysql_connect("localhost","root","123456");
mysql_select_db("db",$link);
$sqlstr="select*from users where ID='".$_POST['ID']."'and passwd='".$_POST['passwd']."'";
$result=mysql_query($sqlstr,$link);
if (mysql_num_rows($result)==1){
echo "<center>会员登录成功</center>";
} else {
echo "<center>会员登录失败</center>";
}
mysql_free_result($result);
mysql_close($link);
?>
程序参考:http://blog.csdn.net/topfzy/archive/2007/06/03/1636146.aspx
create database db;
use db;
create table users (SERIAL int(11) not null primary key auto_increment,ID varchar(20) not null,passwd varchar(20) not null)
会员注册页面 add.php:
<html>
<head>
<meta http-equiv="content-type" content="text/html;charest=GB2312"/>
<title>会员注册</title>
</head>
<body>
<h1 align="center">会员注册</h1>
<form name="form1" action="add_chk.php" method="post">
<p align="center">请输入你要使用的帐号:<input type="text" name="ID"/></p>
<p align="center">请输入你要使用的密码:<input type="password" name="passwd"/></p>
<p align="center">请重新输入密码以确认:<input type="password" name="repasswd"/></p>
<p align="center"><input type="submit" name="提交"/><input type="reset" name="重置"/></p>
</form>
</body>
</html>
注册信息校验页面 add_chk.php:
<?php
$id=$_POST['ID'];
$passwd=$_POST['passwd'];
$repasswd=$_POST['repasswd'];
if($id==null || $passwd==null || $repasswd==NULL)
{ echo "帐号或密码为空,返回重新输入";
}
if ($_POST['passwd']!=$_POST['repasswd'])
{
echo"两次密码不符";
}
$link=mysql_connect("localhost","root","123456");
mysql_select_db("db",$link);
$sqlstr="insert into `users`(SERIAL,ID,passwd) values('','".$_POST['ID']."','".$_POST['passwd']."')";
$result=mysql_query($sqlstr,$link);
echo "注册成功";
mysql_close($link);
?>
登录页面login.php:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312">
<title>会员登录</title>
</head>
<body link="blue" vlink="purple" alink="red">
<h1>会员登录</h1>
<form name="form2" action="chk.php" method="post">
<p align="center">帐号:<input type="text" name="ID"/></p>
<p align="center">密码:<input type="password" name="passwd"/></p>
<p align="center"><input type="submit" name="提交" value="提交"/><input type="reset" name="重置"/>
<h3 align="center"><a href="add.php">注册</a></h3>
</form>
</body>
</html>
登录验证chk.php:
<?php
$link=mysql_connect("localhost","root","123456");
mysql_select_db("db",$link);
$sqlstr="select*from users where ID='".$_POST['ID']."'and passwd='".$_POST['passwd']."'";
$result=mysql_query($sqlstr,$link);
if (mysql_num_rows($result)==1){
echo "<center>会员登录成功</center>";
} else {
echo "<center>会员登录失败</center>";
}
mysql_free_result($result);
mysql_close($link);
?>
程序参考:http://blog.csdn.net/topfzy/archive/2007/06/03/1636146.aspx
相关文章推荐
- 写了一个简单的注册登录模块
- ant design+node.js+mongoose实现一个简单的注册登录功能
- 一个简单的后台与数据库交互的登录与注册[sql注入处理、以及MD5加密]
- 利用node.js+mongodb如何搭建一个简单登录注册的功能详解
- 基于Servlet、JSP、JDBC、MySQL的一个简单的用户注册模块(附完整源码)
- nodejs+mongodb写的一个简单的登录注册
- 小白教程——Windows下用PHP写一个简单的登录注册页面(二)
- python实现一个简单的登录注册Demo
- 由一个简单登录模块引发的安全危机
- 设计一个优雅的登录注册模块
- SSM框架的一个简单登录模块(包含注销功能)
- ruby on rails 注册登录模块的简单实现
- (NodeJS学习文章收集三) node.js基于express框架搭建一个简单的注册登录Web功能
- 基于Servlet、JSP、JDBC、MySQL的一个简单的用户注册模块(附完整源码)
- go语言实现一个简单的登录注册web小程序
- 吴昊品工程级别软件项目 Round 5 —— 用JavaScript实现一个简单的注册登录系统
- 模块化分析设计(简单的注册登录模块)
- 一个简单的PHP登录与注册程序源码
- 用PHP和HTML写一个简单的网站登录注册项目
- JDBC+Servlet+JSP+Mysql写的一个简单的登录注册