php入门教程-用户注册实例程序完整版
<?php // 创建数据库教程连接 mysql_connect('localhost','phprm.com','www.phprm.com'); mysql_select_db('www.phprm.com');//数据库选择 mysql_query('set names "gbk"'); //进度查询操作 ?> <head> <meta http-equiv="Content-Type" content="text/html; charset=gb2312" /> <script language="javascript教程"> check111cnNet() { if (myfm.uid.value == '') { alert('www.phprm.com提示你:用户名错误'); return false; } if (!myfm.pwd.value != '' && myfm.pwd.value == myfm.pwd1.value) { alert('www.phprm.com提示你:二次密码不正确'); return false; } } </script> </head> <body> <form id="myfm" name="myfm" method="post" action=""> <label> 用户名 <input type="text" name="uid" /> <br> 密码 <input type="text" name="pwd" /> <br> 密码2 <input type="text" name="pwd2" /> <br> </label> <label> <input type="submit" name="Submit" value="注册" onClick="return check111cnNet();" /> </label> </form> </body> </html> <?php if ($_POST) { $uid = $_POST['uid']; $pwd = $_POST['pwd']; $pwd1 = $_POST['pwd1']; if (empty($uid)) { exit(); } $sql = "Select * from user where uid ='$uid' limit 0,10"; $query = mysql_query($sql) or die("http://www.phprm.com提示你:查询出错了"); if (mysql_num_rows($query)) { echo '用户己被注册'; } else { if (mysql_query("insert into user(uid,pwd) values('$uid','md5($pwd)')")) { echo 'www.phprm.com提示你:注册成功'; } else { echo '注册失败'; } } }
/*
数据表结构
CREATE TABLE `phprm`.`user` (
`id` INT( 8 ) NOT NULL AUTO_INCREMENT ,
`uid` CHAR( 150 ) NULL ,
`pwd` char(32) NULL ,
PRIMARY KEY ( `id` )
) ENGINE
本教程只供学习用没进行安全处理,如用于商业用途出现任何问题与本站http://www.phprm.com无关
*/
文章网址:http://www.phprm.com/code/bd1a9f096c9a75d51e4955c1ca8582ab.html
随意转载^^但请附上教程地址。