一个简单的注册登录模块

创建数据库:

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

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值