php实现简单的注册系统
用户注册页面 reg.php
创建数据库 mydb.sql
PHP处理注册页面 regcheck.php
reg.php 用户注册页面
部分功能简介:商品收藏夹功能热门商品最新商品分级价格功能自选风格打印结算页面内部短信箱商品评论增加上一商品,下一商品功能增强商家提示功能友情链接用户在线统计用户来访统计用户来访信息用户积分功能广告设置用户组分类邮件系统后台实现更新用户数据系统图片设置模板管理CSS风格管理申诉内容过滤功能用户注册过滤特征字符IP库管理及来访限制及管理压缩,恢复,备份数据库功能上传文件管理商品类别管理商品添加/修改/
0
立即学习“PHP免费学习笔记(深入)”;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>用户注册</title>
</head>
<body>
<form name="frm" method="post" action="checkreg.php">
<table width="31%" border="1" align="center">
<tr>
<td width="30%" height="35" align="right">用户名:</td>
<td width="70%" height="35"><input type="text" name="name" /></td>
</tr>
<tr>
<td width="30%" height="35" align="right">密码:</td>
<td width="70%" height="35"><input type="password" name="password" /></td>
</tr>
<tr>
<td height="35" colspan="2" align="center"><input type="submit" name="sub" value="提交" /></td>
</tr>
</table>
</form>
</body>
</html>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处理用户注册页面
<?php
//获取表单数据
$name=$_POST['name'];
$password=$_POST['password'];
$n=strlen($name);
$p=strlen($password);
if($n==0){
echo "请输入用户名";
}elseif(!($n>=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('{$name}','{$password}')";
//执行sql 语句
mysql_query($sql);
//获得受影响的行数
$row=mysql_affected_rows($conn);
if($row>0)
{
echo "注册成功";
}else{
echo "注册失败";
}
}
?>
PHP怎么学习?PHP怎么入门?PHP在哪学?PHP怎么学才快?不用担心,这里为大家提供了PHP速学教程(入门到精通),有需要的小伙伴保存下载就能学习啦!
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号