php 用户注册页面代码

 更新时间:2016年11月25日 17:33  点击:1997
这款用户注册程序是一款包括有数据库,注册页面,注册js 验证是一款完整理的php+mysql实用的用户注册代码。
 代码如下 复制代码

$conn=mysql_connect('localhost','root','root')or die('数据库连接错误');
mysql_select_db('demo',$conn);
mysql_query("set names 'gbk'");
//检测会员名称是否存在

if($_post[username]){

  $sql="select * from users where username='$_post[username]'";

  $res=mysql_query($sql)or die("查询失败!");
  $us=$_get[name];
  echo $us."222222";
  $ps教程= md5($_post[password]);
  $sex=$_post['sex'];
  $age=$_post['age'];
  $qq=$_post['qq'];
  $phone=$_post['phone'];
  $email=$_post['email'];
  $address=$_post['address'];
  if(is_array(mysql_fetch_row($res))){
       echo "该会员名已经存在!";
  }else{
        $sql="insert into users (username,password,sex,age,qq,phone,email,address) values ('$us','$ps',$sex,$age,$qq,'$phone','$email','$address')";
        echo $sql;
       mysql_query($sql)or die("注册失败");
       echo "<script>alert('注册成功');location.href='login.php'</script>";
  }
}
?>
<script language="网页特效" type="text/javascript">
function docheck(){

var username = document.regform.username.value;
var pwd =document.regform.password.value;
var repwd=document.regform.repassword.value;

if(username==""){
  alert("请输入用户名!");
    return false;
}
if(pwd==""){
  alert("请输入密码!");
    return false;
}
if(repwd != pwd){
  alert("两次填写的密码不相同!");
  return false;
}
}
</script>
<script language="javascript">
function createxmlhttprequest(){
 var xmlhttp;
 if(window.activexobject){
  xmlhttp = new activexobject("microsoft.xmlhttp");
 }else{
  xmlhttp = new xmlhttprequest();
 }
 //return xmlhttp;
}
function checkname(){

 var name = document.getelementbyid('username'); //获取用户名文本框
 var span = document.getelementbyid('name_info'); //获取用于显示结果的span标记
 if(name.value.length <= 4){
  span.style.color = '#ff0000'; //设置span标记内的字体颜色为红色
  span.innerhtml = '用户名长度不能少于4个字符!'; //span标记内容
  return false;
 }
 var xmlhttp = createxmlhttprequest();//创建异步请求对象
 var time = new date().gettime();
 var url = 'regval.php?name=' + name.value + '&tmp=' + time;//构造出请求地址
 xmlhttp.open("get",url,true); //建立一个异步请求
 //这里我们使用get方式请求
 xmlhttp.onreadystatechange = function(){ //监视请求状态
  span.style.color = '#ff9900';
  span.innerhtml = '查询中,请稍候!';

  if(xmlhttp.readystate == 4 && xmlhttp.status == 200){
alert(xmlhttp.responsetext+"........");
   if(xmlhttp.responsetext.indexof('no') != -1){ //如果服务器返回的信息中有no

    span.style.color = '#cb2121'; //设置span标记颜色为红色
    span.innerhtml = '用户名[' + name.value + ']已经被别的用户使用!';
    //document.regform.username.value="";
   }else{//如果返回信息中没有no

    span.style.color = '#00a800';//设置颜色为绿色
    span.innerhtml = '恭喜您,该用户名未被注册!';
   }
   return true;
   delete xmlhttp; //删除请求对象
  }
 }

 xmlhttp.send(null); //发送请求
}
</script>
  <form action="regval.php" method="post" onsubmit="return docheck()" name="regform">
  会员名称:
  <input type="text" name="username" value="" id="username" onblur="checkname()"/>
<span id="name_info"></span>
  <br>
  密&nbsp;&nbsp;&nbsp;&nbsp;码:
  <input type="password" name="password" value=""/><br>
  确认密码:
  <input type="password" name="repassword" value=""/><br>

性别:
男:<input name="sex" type="radio" value="0" checked="checked"/>
女:<input name="sex" type="radio" value="1"/><br>
年龄:<input type="text" name="age" value=""/><br>
qq:<input type="text" name="qq" value=""/><br>
电话:<input type="text" name="phone" value=""/><br>
email:<input type="text" name="email" value=""/><br>
地址:<input type="text" name="address" value=""/><br>
  <input type="submit" name="sub" value="注册"/>
  <input type="reset" name="re" value="取消"/>
  </form>

<?
/*

drop table if exists `users`;
create table `users` (
  `id` int(10) not null auto_increment,
  `username` varchar(50) not null,
  `password` varchar(50) not null,
  `sex` int(1) not null default '0',
  `age` int(10) not null,
  `qq` int(15) default null,
  `phone` varchar(50) default null,
  `email` varchar(50) default null,
  `address` varchar(100) default null,
  primary key (`id`)
) engine=innodb auto_increment=4 default charset=gbk;

-- ----------------------------
-- records of users
-- ----------------------------
insert into `users` values ('1', 'admin', '21232f297a57a5a743894a0e4a801fc3', '0', '22', '379559090', '666666', '666666@163.com', '武汉');
insert into `users` values ('2', 'root', '63a9f0ea7bb98050796b649e85481845', '0', '20', '1244249796', '8888888', '8888888@163.com', '中国');
insert into `users` values ('3', 'www.111cn.net', '96e79218965eb72c92a549dd5a330112', '0', '20', '1244249796', '8888888', '8888888@163.com', '中国');


本教程下载地址

http://down.111cn.net/down/code/php/xinwenxitong/2010/0812/20183.html

 代码如下 复制代码
class ajaxpage{
var $result;
 var $anchors;
 var $total;
 var $db;
 var $网页特效p/jsp.html target=_blank >jsp教程agination;
 function __construct($qry,$starting,$recpage,$jspagination)
 {  
     $this->db   =   &$globals['db'];
  $this->jspagination =  $jspagination;
  $rst  = $this->db->query($qry);
  $numrows = $this->db->num_rows;
  $qry   .= " limit $starting, $recpage";
  
  $this->result = $this->db->get_results($qry,array_a);
  
  $next  = $starting+$recpage;//the number next time end
  //$var  = ((intval($numrows/$recpage))-1)*$recpage;
  $page_showing = intval($starting/$recpage)+1;//the str shows on the page bar
  $total_page = ceil($numrows/$recpage); //total page
  if($numrows % $recpage != 0){
   $last = ((intval($numrows/$recpage)))*$recpage;
  }else{
   $last = ((intval($numrows/$recpage))-1)*$recpage;
  }
  $previous = $starting-$recpage;
  $anc = "<ul id='pagination-flickr'>";
  if($previous < 0){
   $anc .= "<li class='previous-off'>first</li>";
   $anc .= "<li class='previous-off'>previous</li>";
  }else{
   $anc .= "<li class='next'><a href='网页特效:$this->jspagination(0);'>first </a></li>";
   $anc .= "<li class='next'><a href='javascript:$this->jspagination($previous);'>previous </a></li>";
  }
  
  ################if you dont want the numbers just comment this block############### 
  
  $norepeat = 3;//no of pages showing in the left and right side of the current page in the anchors
  $j = 1;
  $anch = "";
  for($i=$page_showing; $i>1; $i--){
   $fpreviouspage = $i-1;
   $page = ceil($fpreviouspage*$recpage)-$recpage;
   $anch = "<li><a href='javascript:$this->jspagination($page);'>$fpreviouspage </a></li>".$anch;
   if($j == $norepeat) break;
   $j++;
  }
  $anc .= $anch;
  $anc .= "<li class='active'>".$page_showing."</li>";
  $j = 1;
  for($i=$page_showing; $i<$total_page; $i++){
   $fnextpage = $i+1;
   $page = ceil($fnextpage*$recpage)-$recpage;
   $anc .= "<li><a href='javascript:$this->jspagination($page);'>$fnextpage</a></li>";
   if($j==$norepeat) break;
   $j++;
  }
  
  ############################################################
  if($next >= $numrows){
   $anc .= "<li class='previous-off'>next</li>";
   $anc .= "<li class='previous-off'>last</li>";
  }else{
   $anc .= "<li class='next'><a href='javascript:$this->jspagination($next);'>next </a></li>";
   $anc .= "<li class='next'><a href='javascript:$this->jspagination($last);'>last</a></li>";
  }
   $anc .= "</ul>";
  $this->anchors = $anc;
  
  $this->totalstr = "page : $page_showing <i> of  </i> $total_page . total records found: $numrows";
 }
}

 

 代码如下 复制代码

mysql教程_connect('localhost','0731-cn','0731licheng1') or die('sever ');
 mysql_select_db('0731-cn') or die('database error');
 $sql = "select uid from member ";
 $query = mysql_query( $sql ) or die('ddd');
 while( $row = mysql_fetch_array( $query ) )
 {
  mysql_query("insert into uc_memberfields(uid,username,password,email,myid,myidkey,regip,regdate,lastloginip,lastlogintime  salt,secques) values('".$row['uid']."','".$row['uid']."')") or die('jjjjj'.mysql_error());

 }


 echo "全部导入";

本文章来讲二种读取文本文件并显示在网页的php实例了,方法很简单,用fopen,加explode,for就实现了。
 代码如下 复制代码
$file = "./text.txt";
$text = fread(fopen($file,"r"),filesize($file));
$line = explode(" ",$text);
echo "<table width=300 border=1 cellspacing=0 cellpadding=0>";
    for($i = 0; $i <= count($line); $i++){
 $txt = explode(" ",$line[$i]);
 echo "<tr><td>".$txt[0]."</td><td>".$txt[1]."</td><td>".$txt[2]."</td><td>".$txt[3]."</td></tr>";
    }
echo "</table>";

//方法二

 代码如下 复制代码

$content = file_get_contents('test.txt');

$arr = explode(" ", $content);
echo "<table>";

foreach ($arr as $v) {
$tmp = explode("    ", $v);
echo "<tr>";
echo "<td>" . $tmp[0] . "</td>";
echo "<td>" . $tmp[1] . "</td>";
echo "<td>" . $tmp[2] . "</td>";
echo "<td>" . $tmp[3] . "</td>";
echo "</tr>";
unset($tmp);
}

echo "</table>";

//其实不有一个方法来实现上的实例,file函数哦,这个我也不说多了。查查就知道了,它读出内容直接保存到数据,就不用我们使用explode函数了。
/*
文本文本格式如下

读取一个文本文件内容如下
1       aaaa    bbba    ccca
2       aaaa    bbbb    cccb
3       aaaa    bbbc    cccc
3       aaaa    bbbc    cccc

 

这是一款利用mysql php实例的用户注册代码,比较简单,就是把html提交过来的数据保存到mysql数据库。

 include('global.php');

 代码如下 复制代码

 if($_post['sub']){
  $user  = $_post['username'];
  $pwd   = md5($_post['password1'].$user);
  $email = $_post['email'];
   $q = $mysql->query("insert into `hl`.`hl_member`(`id`,`username`,`password`,`email`)values (null,'$user','$pwd','$email');");
  if($q){
   setcookie('login',$user);
   $prompt_msg->p('恭喜您,亲爱的会员,您已经注册成功!','index.php','现在去首页。','http://www.111cn.net','先去论坛逛逛!');
  }else{
   $prompt_msg->p('非常抱歉,系统发生故障!');
  }
 }
?>

<!doctype html public "-//w3c//dtd xhtml 1.0 transitional//en" "http://www.w3.org/tr/xhtml1/dtd/xhtml1-transitional.dtd">
<html xmlns="http://www.111cn.net/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html; charset=gb2312" />
<title></title>
<link rel="stylesheet" type="text/css教程" href="css/reg_log.css" />

</head>

<body>
<form id="myform" name="myform" method="post" action="register.php">
<div id="top">注册&nbsp;<a href="login.php">登录</a></div>
<div id="content">
 <div class="c1">请填写以下必填信息完成注册</div>
    <div class="c2"><span>带红色*的都是必填项目,若填写不全将无法注册</span></div>
    <div class="cinput"><dl>
     <dt>用户名<font color="red">*</font></dt>
        <dd><input id="username" name="username" type="text" maxlength="12" /></dd>
        <dd id="user_prompt" class="prompt">大小写英文字母、汉字、数字、下划线组成的长度 3-12 个字节以内</dd>
    </dl></div>
    <div class="cinput"><dl>
     <dt>密&nbsp;&nbsp;码<font color="red">*</font></dt>
        <dd><input id="password1" name="password1" type="password" maxlength="16" /></dd>
        <dd id="pwd1_prompt" class="prompt">最小长度:6 最大长度:16,仅限字母、数字及_,字母区分大小写</dd>
    </dl></div>         
    <!--检测密码强度-->
 <div class="cinput" style="padding-bottom:0px;"><!--ie6 hack-->
     <div class="chkpwd">
         <span id="cp1_prompt" class="cp1"></span><span id="cp2_prompt" class="cp2"></span>
            <span id="cp3_prompt" class="cp3"></span>
     </div>
    </div>
    <div class="cinput" style="padding-top:0px;"><dl>
     <dt>确认密码<font color="red">*</font></dt>
        <dd><input id="password2" name="password2" type="password" maxlength="16" /></dd>
        <dd id="pwd2_prompt" class="prompt">请再输入一遍您上面填写的密码</dd>
    </dl></div>
    <div class="cinput"><dl>
     <dt>email<font color="red">*</font></dt>
        <dd><input id="email" name="email" type="text" /></dd>
        <dd id="email_prompt" class="prompt">请填写真实并且最常用的邮箱</dd>
    </dl></div>
    <div style="clear:both"></div>
</div>
<div id="bottom">
 <input class="btn1" type="submit" name="sub" value="提交注册" id="checkall" />
 <input class="btn2" type="reset" name="reset" value="重置" onclick="return sub(this.form)" />
</div>
</form>
</body>
</html>

数据库结构

 create table `hl`.`hl_member` (
`id` int( 4 ) not null auto_increment comment '自动编码',
`username` varchar( 100 ) not null comment '用户名称',
`password` varchar( 200 ) not null comment '用户密码',
`answer` varchar( 100 ) not null comment '密保答案',
`question` varchar( 100 ) not null comment '密保问题',
`email` varchar( 100 ) not null comment 'email',
`realname` varchar( 200 ) not null comment '登录限制',
`birthday` date not null comment '出生日期',
`telephone` varchar( 20 ) not null comment '电话号码',
`qq` varchar( 15 ) not null comment 'qq号码',
`count` int( 1 ) not null comment '登录限制',
`active` int( 1 ) not null comment '是否激活',
primary key ( `id` )
) engine = innodb character set gb2312 collate gb2312_chinese_ci;

[!--infotagslink--]

相关文章

  • php 获取用户IP与IE信息程序

    php 获取用户IP与IE信息程序 function onlineip() { global $_SERVER; if(getenv('HTTP_CLIENT_IP')) { $onlineip = getenv('HTTP_CLIENT_IP');...2016-11-25
  • 不打开网页直接查看网站的源代码

      有一种方法,可以不打开网站而直接查看到这个网站的源代码..   这样可以有效地防止误入恶意网站...   在浏览器地址栏输入:   view-source:http://...2016-09-20
  • php 调用goolge地图代码

    <?php require('path.inc.php'); header('content-Type: text/html; charset=utf-8'); $borough_id = intval($_GET['id']); if(!$borough_id){ echo ' ...2016-11-25
  • JS基于Mootools实现的个性菜单效果代码

    本文实例讲述了JS基于Mootools实现的个性菜单效果代码。分享给大家供大家参考,具体如下:这里演示基于Mootools做的带动画的垂直型菜单,是一个初学者写的,用来学习Mootools的使用有帮助,下载时请注意要将外部引用的mootools...2015-10-23
  • JS+CSS实现分类动态选择及移动功能效果代码

    本文实例讲述了JS+CSS实现分类动态选择及移动功能效果代码。分享给大家供大家参考,具体如下:这是一个类似选项卡功能的选择插件,与普通的TAb区别是加入了动画效果,多用于商品类网站,用作商品分类功能,不过其它网站也可以用,...2015-10-21
  • JS实现自定义简单网页软键盘效果代码

    本文实例讲述了JS实现自定义简单网页软键盘效果。分享给大家供大家参考,具体如下:这是一款自定义的简单点的网页软键盘,没有使用任何控件,仅是为了练习JavaScript编写水平,安全性方面没有过多考虑,有顾虑的可以不用,目的是学...2015-11-08
  • php 取除连续空格与换行代码

    php 取除连续空格与换行代码,这些我们都用到str_replace与正则函数 第一种: $content=str_replace("n","",$content); echo $content; 第二种: $content=preg_replac...2016-11-25
  • php简单用户登陆程序代码

    php简单用户登陆程序代码 这些教程很对初学者来讲是很有用的哦,这款就下面这一点点代码了哦。 <center> <p>&nbsp;</p> <p>&nbsp;</p> <form name="form1...2016-11-25
  • PHP实现清除wordpress里恶意代码

    公司一些wordpress网站由于下载的插件存在恶意代码,导致整个服务器所有网站PHP文件都存在恶意代码,就写了个简单的脚本清除。恶意代码示例...2015-10-23
  • JS实现双击屏幕滚动效果代码

    本文实例讲述了JS实现双击屏幕滚动效果代码。分享给大家供大家参考,具体如下:这里演示双击滚屏效果代码的实现方法,不知道有觉得有用处的没,现在网上还有很多还在用这个特效的呢,代码分享给大家吧。运行效果截图如下:在线演...2015-10-30
  • js识别uc浏览器的代码

    其实挺简单的就是if(navigator.userAgent.indexOf('UCBrowser') > -1) {alert("uc浏览器");}else{//不是uc浏览器执行的操作}如果想测试某个浏览器的特征可以通过如下方法获取JS获取浏览器信息 浏览器代码名称:navigator...2015-11-08
  • JS日期加减,日期运算代码

    一、日期减去天数等于第二个日期function cc(dd,dadd){//可以加上错误处理var a = new Date(dd)a = a.valueOf()a = a - dadd * 24 * 60 * 60 * 1000a = new Date(a)alert(a.getFullYear() + "年" + (a.getMonth() +...2015-11-08
  • PHP开发微信支付的代码分享

    微信支付,即便交了保证金,你还是处理测试阶段,不能正式发布。必须到你通过程序测试提交订单、发货通知等数据到微信的系统中,才能申请发布。然后,因为在微信中是通过JS方式调用API,必须在微信后台设置支付授权目录,而且要到...2014-05-31
  • PHP常用的小程序代码段

    本文实例讲述了PHP常用的小程序代码段。分享给大家供大家参考,具体如下:1.计算两个时间的相差几天$startdate=strtotime("2009-12-09");$enddate=strtotime("2009-12-05");上面的php时间日期函数strtotime已经把字符串...2015-11-24
  • php根据用户语言跳转相应网页

    当来访者浏览器语言是中文就进入中文版面,国外的用户默认浏览器不是中文的就跳转英文页面。 <&#63;php $lan = substr(&#8194;$HTTP_ACCEPT_LANGUAGE,0,5); if ($lan == "zh-cn") print("<meta http-equiv='refresh' c...2015-11-08
  • php怎么用拼音 简单的php中文转拼音的实现代码

    小编分享了一段简单的php中文转拼音的实现代码,代码简单易懂,适合初学php的同学参考学习。 代码如下 复制代码 <?phpfunction Pinyin($_String...2017-07-06
  • js检测用户输入密码强度

    一个用Javascript检测用户输入密码强度的效果代码,以下代码主要是从以下四个方面检测用户输入的密码的强度的,有兴趣的朋友可以自己添加或修改成自己想要的形式! 1. 如果输入的密码位数少于5位,那么就判定为弱。 2. 如果...2015-10-23
  • php有效防止同一用户多次登录

    【问题描述】:同一用户在同一时间多次登录如果不能检测出来,是危险的。因为,你无法知道是否有其他用户在登录你的账户。如何禁止同一用户多次登录呢? 【解决方案】 (1) 每次登录,身份认证成功后,重新产生一个session_id。 s...2015-11-24
  • 几种延迟加载JS代码的方法加快网页的访问速度

    本文介绍了如何延迟javascript代码的加载,加快网页的访问速度。 当一个网站有很多js代码要加载,js代码放置的位置在一定程度上将会影像网页的加载速度,为了让我们的网页加载速度更快,本文总结了一下几个注意点...2013-10-13
  • php导出csv格式数据并将数字转换成文本的思路以及代码分享

    php导出csv格式数据实现:先定义一个字符串 存储内容,例如 $exportdata = '规则111,规则222,审222,规222,服2222,规则1,规则2,规则3,匹配字符,设置时间,有效期'."/n";然后对需要保存csv的数组进行foreach循环,例如复制代...2014-06-07