作者:zbdxyyj | 来源:互联网 | 2018-03-23 04:23
php实现简单的注册系统
用户注册页面 reg.php
创建数据库 mydb.sql
PHP处理注册页面 regcheck.php
reg.php 用户注册页面
mydb.sql 数据库
create database user;
use user;
create table yinfu(
userId int unsigned not null auto_increment primary key,
name varchar(20) not null,
password varchar(20) not null
);
checkreg.php php处理用户注册页面
=5 && $n<=16)){
echo "用户名长度为5-16位";
}elseif($p==0){
echo "请输入密码";
}elseif(!($p>=5 && $p<=16)){
echo "密码长度为5-16位";
}else{
//连接数据库
$cOnn=mysql_connect("localhost","root","123456") or die("数据库连接失败");
//选择数据库
mysql_select_db("user");
//设置数据库编码
mysql_query("set names utf8");
//将表单获得的数据插入数据库
$sql="insert into yinfu(name,password)values(&#39;{$name}&#39;,&#39;{$password}&#39;)";
//执行sql 语句
mysql_query($sql);
//获得受影响的行数
$row=mysql_affected_rows($conn);
if($row>0)
{
echo "注册成功";
}else{
echo "注册失败";
}
}
?>